Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade #184

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/delegator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"resolutions": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1",
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3",
"typescript": "^4.5.4"
},
"dependencies": {
Expand Down
12 changes: 6 additions & 6 deletions examples/erc20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"node": ">=14.x"
},
"resolutions": {
"@polkadot/api": "7.10.1",
"@polkadot/api-contract": "7.10.1",
"@polkadot/types": "7.10.1",
"@polkadot/keyring": "8.4.1",
"@polkadot/util": "8.4.1",
"@polkadot/api": "8.11.3",
"@polkadot/api-contract": "8.11.3",
"@polkadot/types": "8.11.3",
"@polkadot/keyring": "9.7.2",
"@polkadot/util": "9.7.2",
"@polkadot/wasm-crypto": "4.5.1",
"@polkadot/util-crypto": "8.4.1",
"@polkadot/util-crypto": "9.7.2",
"typescript": "4.5.4"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"resolutions": {
"@polkadot/api": "7.10.1",
"@polkadot/api-contract": "7.10.1",
"@polkadot/api": "8.11.3",
"@polkadot/api-contract": "8.11.3",
"typescript": "^4.5.4"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions examples/plasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"node": ">=14.x"
},
"resolutions": {
"@polkadot/api": "7.10.1",
"@polkadot/api-contract": "7.10.1",
"@polkadot/types": "7.10.1",
"@polkadot/util": "^8.4.1",
"@polkadot/api": "8.11.3",
"@polkadot/api-contract": "8.11.3",
"@polkadot/types": "8.11.3",
"@polkadot/util": "^9.7.2",
"typescript": "^4.5.4"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/solang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"resolutions": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1",
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3",
"typescript": "^4.5.4"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"yarn": "^1.10.1"
},
"resolutions": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1",
"@polkadot/types": "^7.10.1",
"@polkadot/util": "^8.4.1"
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3",
"@polkadot/types": "^8.11.3",
"@polkadot/util": "^9.7.2"
},
"workspaces": [
"packages/*"
Expand Down
4 changes: 2 additions & 2 deletions packages/redspot-chai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"redspot": "^0.13.6"
},
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1",
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3",
"chai-as-promised": "^7.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/redspot-chai/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import chaiAsPromised from 'chai-as-promised'
import chaiAsPromised from 'chai-as-promised';

export function init(projectRoot: string) {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/redspot-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=8.2.0"
},
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/api": "^8.11.3",
"abort-controller": "^3.0.0",
"bn.js": "^5.1.3",
"chalk": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/redspot-core/src/builtin-tasks/compile-ink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subtask(
input,
redspotArguments.verbose,
redspotArguments.release,
redspotArguments.skipLinting,
redspotArguments.skipLinting
);

return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ export const hexString = new t.Type<string>(
t.identity
);

const NetworkConfigAccounts = t.union([t.array(t.string), t.array(t.type({
mnemonic: optional(t.string),
initialIndex: optional(t.number),
count: optional(t.number),
path: optional(t.string)
}),'HDAccountsUserConfig')])
const NetworkConfigAccounts = t.union([
t.array(t.string),
t.array(
t.type({
mnemonic: optional(t.string),
initialIndex: optional(t.number),
count: optional(t.number),
path: optional(t.string)
}),
'HDAccountsUserConfig'
)
]);

const HttpHeaders = t.record(t.string, t.string, 'httpHeaders');

Expand Down
20 changes: 10 additions & 10 deletions packages/redspot-core/src/provider/account-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { u8aToHex } from '@polkadot/util';
import { RedspotError } from '../internal/core/errors';
import { ERRORS } from '../internal/core/errors-list';
import log from '../logger';
import type {HDAccountsUserConfig, LocalKeyringPair} from '../types';
import type { HDAccountsUserConfig, LocalKeyringPair } from '../types';
import { RedspotNetworkAccountsUserConfig } from '../types';

let id = 0;
Expand Down Expand Up @@ -86,18 +86,17 @@ export class Signer implements PolkadotSigner {
log.error(error.message);
throw new RedspotError(ERRORS.GENERAL.BAD_SURI, { uri: account });
}
}
else if (typeof account == 'object') {
const _account = account as HDAccountsUserConfig
} else if (typeof account === 'object') {
const _account = account;
try {
const mnemonic = _account.mnemonic;

pair = this.keyring.addFromUri(mnemonic);
(pair as LocalKeyringPair).suri = mnemonic;

if (_account.path) {
let initialIndex = _account.initialIndex || 0;
let count = _account.count || 20;
const initialIndex = _account.initialIndex || 0;
const count = _account.count || 20;
pair.lock = (): void => {};
if (initialIndex >= count) {
return;
Expand All @@ -106,14 +105,15 @@ export class Signer implements PolkadotSigner {
const derivedPath = `${_account.path}/${i}`;
const childPair = pair.derive(derivedPath);
(childPair as LocalKeyringPair).suri = mnemonic + derivedPath;
this.keyring.addPair(childPair)
this.keyring.addPair(childPair);
}
}
} catch (error) {
log.error(error.message)
throw new RedspotError(ERRORS.GENERAL.BAD_SURI, { uri: _account.mnemonic });
log.error(error.message);
throw new RedspotError(ERRORS.GENERAL.BAD_SURI, {
uri: _account.mnemonic
});
}

}
}
};
Expand Down
9 changes: 7 additions & 2 deletions packages/redspot-core/src/provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { createProvider, createApi, createNetwork, createSigner } from './construction';
export {
createProvider,
createApi,
createNetwork,
createSigner
} from './construction';
export { Signer as AccountSigner } from './account-signer';
export { Signer } from './signer'
export { Signer } from './signer';
9 changes: 4 additions & 5 deletions packages/redspot-core/src/provider/ws-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class WsProvider implements ProviderInterface {
): Promise<T> {
const body = this._coder.encodeJson(method, params);
let resultPromise: Promise<T> | null = isCacheable
? (this._callCache.get(body) as Promise<T>)
? this._callCache.get(body)
: null;

if (!resultPromise) {
Expand Down Expand Up @@ -381,7 +381,7 @@ export class WsProvider implements ProviderInterface {
const id = this._coder.getId();

const callback = (error?: Error | null, result?: T): void => {
error ? reject(error) : resolve(result as T);
error ? reject(error) : resolve(result);
};

log.debug(
Expand Down Expand Up @@ -512,7 +512,7 @@ export class WsProvider implements ProviderInterface {
};

_onSocketMessage = (message: MessageEvent<string>): void => {
const response = JSON.parse(message.data as string) as JsonRpcResponse;
const response = JSON.parse(message.data) as JsonRpcResponse;
const isMsg = isUndefined(response.method);

if (isMsg) {
Expand Down Expand Up @@ -571,8 +571,7 @@ export class WsProvider implements ProviderInterface {
};

_onSocketMessageSubscribe = (response: JsonRpcResponse): void => {
const method =
ALIASES[response.method as string] || response.method || 'invalid';
const method = ALIASES[response.method] || response.method || 'invalid';
const subId = `${method}::${response.params.subscription}`;
const handler = this._subscriptions[subId];

Expand Down
12 changes: 6 additions & 6 deletions packages/redspot-core/src/types/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ interface SpecDef {
events: any[];
messages: {
label: string;
name: string[] | string
selector: string
}[]
name: string[] | string;
selector: string;
}[];
}

export type AbiMetadata = {
Expand All @@ -25,13 +25,13 @@ export type AbiMetadata = {
spec: SpecDef;
V1: {
spec: SpecDef;
},
};
V2: {
spec: SpecDef;
},
};
V3: {
spec: SpecDef;
}
};
};

export interface Artifacts {
Expand Down
4 changes: 3 additions & 1 deletion packages/redspot-core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import type { ApiOptions } from '@polkadot/api/types';
import type BN from 'bn.js';

// Networks config
export type RedspotNetworkAccountsUserConfig = string[] | HDAccountsUserConfig[];
export type RedspotNetworkAccountsUserConfig =
| string[]
| HDAccountsUserConfig[];

export interface RedspotNetworkUserConfig {
endpoint?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/redspot-decimals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"redspot": "^0.13.6"
},
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1"
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3"
}
}
12 changes: 7 additions & 5 deletions packages/redspot-gas-reporter/src/reporter/Watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TransactionWatcher {

constructor(config: GasReporterConfig) {
this.#abiMap = (config.abis || []).reduce((result, data) => {
const abiData = this.getAbiData(data)
const abiData = this.getAbiData(data);
// Compatible with older version abi
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand All @@ -48,15 +48,17 @@ export class TransactionWatcher {
this.#extrinsics = [];
}

getAbiData(data:AbiMetadata) {
getAbiData(data: AbiMetadata) {
let abiData = data;
// new styles
// Find the different metadata version key, V1, V2, V3, etc.
const storageKey = Object.keys(abiData).filter(key => key.search(/V\d/) > -1)
const storageKey = Object.keys(abiData).filter(
(key) => key.search(/V\d/) > -1
);
if (storageKey.length) {
abiData = abiData[storageKey[0]]
abiData = abiData[storageKey[0]];
}
return abiData
return abiData;
}

async ensureConnect() {
Expand Down
6 changes: 4 additions & 2 deletions packages/redspot-jupiter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ extendEnvironment((env) => {

if (!isJupiter) return _encodedSalt(salt, signerAddress);

const nonceCodec = await env.network.api.query.system.accountNonce(signerAddress);
const nonceCodec = await env.network.api.query.system.accountNonce(
signerAddress
);

const nonce = nonceCodec.toHuman()['nonce']
const nonce = nonceCodec.toHuman().nonce;

return salt instanceof Bytes ? salt : compactAddLength(numberToU8a(nonce));
};
Expand Down
2 changes: 1 addition & 1 deletion packages/redspot-known-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"redspot": "^0.13.6"
},
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/api": "^8.11.3",
"@polkadot/apps-config": "^0.103.1"
}
}
4 changes: 2 additions & 2 deletions packages/redspot-patract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"redspot": "^0.13.6"
},
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/api-contract": "^7.10.1"
"@polkadot/api": "^8.11.3",
"@polkadot/api-contract": "^8.11.3"
}
}
13 changes: 9 additions & 4 deletions packages/redspot-patract/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function populateTransaction(
callParams.value,
callParams.gasLimit,
storageDepositLimit,
//@ts-ignore
// @ts-ignore
callParams.inputData
)
: // eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down Expand Up @@ -216,7 +216,9 @@ function buildCall(

const _contractCallFn = contract.api.rpc.contracts.call;

const json = await (at ? _contractCallFn(rpcParams, at) : _contractCallFn(rpcParams));
const json = await (at
? _contractCallFn(rpcParams, at)
: _contractCallFn(rpcParams));

const {
debugMessage,
Expand Down Expand Up @@ -458,12 +460,15 @@ export default class Contract {

/**
* Query at specific block
*
*
* @param at string | Uint8Array
* @param abi AbiMessage
* @returns ContractFunction\<ContractCallOutcome\>
*/
public queryAt(at: string | Uint8Array, abi: AbiMessage): ContractFunction<ContractCallOutcome> {
public queryAt(
at: string | Uint8Array,
abi: AbiMessage
): ContractFunction<ContractCallOutcome> {
return buildCall(this, abi, false, at);
}

Expand Down
Loading