@autonomys/auto-utils 0.1.4 → 0.1.6-devnet-support
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/address.d.ts +3 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +10 -0
- package/dist/api.d.ts +4 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +30 -14
- package/dist/constants/network.d.ts.map +1 -1
- package/dist/constants/network.js +25 -0
- package/dist/constants/wallet.d.ts +1 -0
- package/dist/constants/wallet.d.ts.map +1 -1
- package/dist/constants/wallet.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/network.d.ts +5 -5
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -4
- package/dist/types/event.d.ts +5 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/extrinsic.d.ts +5 -0
- package/dist/types/extrinsic.d.ts.map +1 -0
- package/dist/types/extrinsic.js +3 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/network.d.ts +5 -2
- package/dist/types/network.d.ts.map +1 -1
- package/dist/types/network.js +0 -1
- package/dist/types/transaction.d.ts +14 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/transaction.js +3 -0
- package/dist/types/wallet.d.ts +24 -2
- package/dist/types/wallet.d.ts.map +1 -1
- package/dist/utils/createType.d.ts +3 -0
- package/dist/utils/createType.d.ts.map +1 -0
- package/dist/utils/createType.js +6 -0
- package/dist/utils/detectTxSuccess.d.ts +3 -0
- package/dist/utils/detectTxSuccess.d.ts.map +1 -0
- package/dist/utils/detectTxSuccess.js +13 -0
- package/dist/utils/events.d.ts +11 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +19 -0
- package/dist/utils/format.d.ts +3 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +6 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/ready.d.ts +3 -0
- package/dist/utils/ready.d.ts.map +1 -0
- package/dist/utils/ready.js +5 -0
- package/dist/utils/sign.d.ts +6 -0
- package/dist/utils/sign.d.ts.map +1 -0
- package/dist/utils/sign.js +27 -0
- package/dist/utils/signAndSendTx.d.ts +3 -0
- package/dist/utils/signAndSendTx.d.ts.map +1 -0
- package/dist/utils/signAndSendTx.js +52 -0
- package/dist/utils/validateEvents.d.ts +3 -0
- package/dist/utils/validateEvents.d.ts.map +1 -0
- package/dist/utils/validateEvents.js +24 -0
- package/dist/utils/verify.d.ts +4 -0
- package/dist/utils/verify.d.ts.map +1 -0
- package/dist/utils/verify.js +7 -0
- package/dist/wallet.d.ts +6 -12
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +47 -22
- package/package.json +2 -2
- package/dist/types/api.d.ts +0 -3
- package/dist/types/api.d.ts.map +0 -1
- /package/dist/types/{api.js → event.js} +0 -0
package/README.md
CHANGED
|
@@ -6,17 +6,17 @@ The Autonomys Auto SDK Utility provides functionalities for wallet setup, networ
|
|
|
6
6
|
|
|
7
7
|
## Wallet Management
|
|
8
8
|
|
|
9
|
-
- `setupWallet(
|
|
10
|
-
- `activateWallet(
|
|
11
|
-
- `mockWallets(network:
|
|
9
|
+
- `setupWallet(params: MnemonicOrURI): Promise<KeyringPair>`: Initializes a wallet using a mnemonic or URI.
|
|
10
|
+
- `activateWallet(params: ActivateWalletParams): Promise<WalletActivated>`: Activates a wallet and returns API and accounts.
|
|
11
|
+
- `mockWallets(network: NetworkParams | DomainParams): Promise<WalletActivated[]>`: Creates mock wallets for testing.
|
|
12
12
|
- `getMockWallet(name: string, wallets: WalletActivated[]): WalletActivated`: Retrieves a mock wallet by name.
|
|
13
13
|
|
|
14
14
|
## Network Management
|
|
15
15
|
|
|
16
|
-
- `getNetworkDetails(input?:
|
|
17
|
-
- `getNetworkRpcUrls(input?:
|
|
18
|
-
- `getNetworkDomainDetails(
|
|
19
|
-
- `getNetworkDomainRpcUrls(
|
|
16
|
+
- `getNetworkDetails(input?: NetworkParams): Network`: Gets network details.
|
|
17
|
+
- `getNetworkRpcUrls(input?: NetworkParams): string[]`: Gets network RPC URLs.
|
|
18
|
+
- `getNetworkDomainDetails(params: DomainParams): Domain`: Gets domain details.
|
|
19
|
+
- `getNetworkDomainRpcUrls(params: DomainParams): string[]`: Gets domain RPC URLs.
|
|
20
20
|
|
|
21
21
|
## Data Storage
|
|
22
22
|
|
|
@@ -31,8 +31,8 @@ The Autonomys Auto SDK Utility provides functionalities for wallet setup, networ
|
|
|
31
31
|
|
|
32
32
|
## API Activation
|
|
33
33
|
|
|
34
|
-
- `activate(input?:
|
|
35
|
-
- `activateDomain(
|
|
34
|
+
- `activate(input?: NetworkParams): Promise<ApiPromise>`: Activates the API for a network.
|
|
35
|
+
- `activateDomain(params: DomainParams): Promise<ApiPromise>`: Activates the API for a domain.
|
|
36
36
|
- `disconnect()`: Disconnects the API.
|
|
37
37
|
- `disconnectDomain()`: Disconnects the domain API.
|
|
38
38
|
|
|
@@ -44,7 +44,7 @@ The Autonomys Auto SDK Utility provides functionalities for wallet setup, networ
|
|
|
44
44
|
|
|
45
45
|
## Types
|
|
46
46
|
|
|
47
|
-
- `Network`, `Domain`, `Explorer`, `
|
|
47
|
+
- `Network`, `Domain`, `Explorer`, `NetworkParams`, `DomainParams`
|
|
48
48
|
- `Mnemonic`, `URI`, `AppName`, `MnemonicOrURI`
|
|
49
49
|
|
|
50
50
|
For more details, refer to the source files in the `src` directory.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,YAAa,MAAM,GAAG,UAAU,KAAG,MACV,CAAA;AAE7C,eAAO,MAAM,MAAM,YAAa,MAAM,KAAG,UAAoC,CAAA"}
|
package/dist/address.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/address.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.decode = exports.address = void 0;
|
|
5
|
+
const keyring_1 = require("@polkadot/keyring");
|
|
6
|
+
const wallet_1 = require("./constants/wallet");
|
|
7
|
+
const address = (address) => (0, keyring_1.encodeAddress)(address, wallet_1.DEFAULT_SS58_FORMAT);
|
|
8
|
+
exports.address = address;
|
|
9
|
+
const decode = (address) => (0, keyring_1.decodeAddress)(address);
|
|
10
|
+
exports.decode = decode;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiPromise } from '@polkadot/api';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
import type { ActivateParams, ApiOptions, DomainParams, NetworkParams } from './types/network';
|
|
3
|
+
export declare const createConnection: (endpoint: string, options?: ApiOptions) => Promise<ApiPromise>;
|
|
4
|
+
export declare const activate: (params?: ActivateParams<NetworkParams>) => Promise<ApiPromise>;
|
|
5
|
+
export declare const activateDomain: (params: ActivateParams<DomainParams>) => Promise<ApiPromise>;
|
|
5
6
|
export declare const disconnect: (api: ApiPromise) => Promise<void>;
|
|
6
7
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,eAAe,CAAA;AAEtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,eAAe,CAAA;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE9F,eAAO,MAAM,gBAAgB,aACjB,MAAM,YACN,UAAU,KACnB,QAAQ,UAAU,CAYpB,CAAA;AAED,eAAO,MAAM,QAAQ,YAAmB,eAAe,aAAa,CAAC,KAAG,QAAQ,UAAU,CAOzF,CAAA;AAED,eAAO,MAAM,cAAc,WAAkB,eAAe,YAAY,CAAC,KAAG,QAAQ,UAAU,CAO7F,CAAA;AAED,eAAO,MAAM,UAAU,QAAe,UAAU,KAAG,QAAQ,IAAI,CAG9D,CAAA"}
|
package/dist/api.js
CHANGED
|
@@ -8,30 +8,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.disconnect = exports.activateDomain = exports.activate = void 0;
|
|
23
|
+
exports.disconnect = exports.activateDomain = exports.activate = exports.createConnection = void 0;
|
|
13
24
|
const api_1 = require("@polkadot/api");
|
|
14
25
|
const network_1 = require("./network");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const rpcUrl = (0, network_1.getNetworkRpcUrls)(input);
|
|
26
|
+
const createConnection = (endpoint, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
18
28
|
// Create the provider
|
|
19
|
-
const provider = new api_1.WsProvider(
|
|
29
|
+
const provider = new api_1.WsProvider(endpoint);
|
|
20
30
|
// Create the API instance
|
|
21
|
-
const api = yield api_1.ApiPromise.create({ provider });
|
|
31
|
+
const api = yield api_1.ApiPromise.create(Object.assign(Object.assign({}, options), { noInitWarn: (_a = options === null || options === void 0 ? void 0 : options.noInitWarn) !== null && _a !== void 0 ? _a : true, provider }));
|
|
22
32
|
yield api.isReady;
|
|
23
33
|
return api;
|
|
24
34
|
});
|
|
35
|
+
exports.createConnection = createConnection;
|
|
36
|
+
const activate = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
// Get the first rpc urls for the network
|
|
38
|
+
const endpoint = (0, network_1.getNetworkRpcUrls)(params);
|
|
39
|
+
// Remove the networkId from the input
|
|
40
|
+
if (params)
|
|
41
|
+
delete params.networkId;
|
|
42
|
+
return yield (0, exports.createConnection)(endpoint[0], params);
|
|
43
|
+
});
|
|
25
44
|
exports.activate = activate;
|
|
26
|
-
const activateDomain = (
|
|
45
|
+
const activateDomain = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
46
|
// Get the first rpc urls for the network
|
|
28
|
-
const
|
|
29
|
-
//
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const api = yield api_1.ApiPromise.create({ provider });
|
|
33
|
-
yield api.isReady;
|
|
34
|
-
return api;
|
|
47
|
+
const endpoint = (0, network_1.getNetworkDomainRpcUrls)(params);
|
|
48
|
+
// Remove the domainId from the input
|
|
49
|
+
const { domainId } = params, rest = __rest(params, ["domainId"]);
|
|
50
|
+
return yield (0, exports.createConnection)(endpoint[0], rest);
|
|
35
51
|
});
|
|
36
52
|
exports.activateDomain = activateDomain;
|
|
37
53
|
const disconnect = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/constants/network.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,eAAO,MAAM,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/constants/network.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,eAAO,MAAM,QAAQ,EAAE,OAAO,EAkF7B,CAAA;AAED,eAAO,MAAM,cAAc,SAAc,CAAA"}
|
|
@@ -34,6 +34,31 @@ exports.networks = [
|
|
|
34
34
|
],
|
|
35
35
|
isTestnet: true,
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
id: 'autonomys-devnet',
|
|
39
|
+
name: 'Autonomys - Devnet',
|
|
40
|
+
rpcUrls: ['ws://rpc.devnet.subspace.network/ws'],
|
|
41
|
+
explorer: [
|
|
42
|
+
{
|
|
43
|
+
name: 'Astral',
|
|
44
|
+
url: 'https://explorer.subspace.network/devnet/consensus/',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
domains: [
|
|
48
|
+
{
|
|
49
|
+
id: 'auto-id', // Placeholder
|
|
50
|
+
name: 'Autonomys - Auto-ID',
|
|
51
|
+
rpcUrls: ['ws://autoid.devnet.subspace.network/ws'],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'auto-evm', // Placeholder
|
|
55
|
+
name: 'Autonomys - Auto-EVM (Nova)',
|
|
56
|
+
rpcUrls: ['https:///nova.devnet.subspace.network/ws'],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
isTestnet: true,
|
|
60
|
+
isLocalhost: false,
|
|
61
|
+
},
|
|
37
62
|
{
|
|
38
63
|
id: 'autonomys-localhost',
|
|
39
64
|
name: 'Autonomys - Localhost',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/constants/wallet.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAWpB,CAAA"}
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/constants/wallet.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAWpB,CAAA;AAED,eAAO,MAAM,mBAAmB,OAAO,CAAA"}
|
package/dist/constants/wallet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// file: src/constants/wallet.ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.mockURIs = void 0;
|
|
4
|
+
exports.DEFAULT_SS58_FORMAT = exports.mockURIs = void 0;
|
|
5
5
|
exports.mockURIs = [
|
|
6
6
|
'//Alice',
|
|
7
7
|
'//Bob',
|
|
@@ -14,3 +14,4 @@ exports.mockURIs = [
|
|
|
14
14
|
'//Ivy',
|
|
15
15
|
'//Jacob',
|
|
16
16
|
];
|
|
17
|
+
exports.DEFAULT_SS58_FORMAT = 2254;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './address';
|
|
1
2
|
export * from './api';
|
|
2
3
|
export * from './crypto';
|
|
3
4
|
export * from './network';
|
|
@@ -7,4 +8,5 @@ export * from './save';
|
|
|
7
8
|
export * from './wallet';
|
|
8
9
|
export * from './constants';
|
|
9
10
|
export * from './types';
|
|
11
|
+
export * from './utils';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AAExB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AAExB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./address"), exports);
|
|
18
19
|
__exportStar(require("./api"), exports);
|
|
19
20
|
__exportStar(require("./crypto"), exports);
|
|
20
21
|
__exportStar(require("./network"), exports);
|
|
@@ -24,3 +25,4 @@ __exportStar(require("./save"), exports);
|
|
|
24
25
|
__exportStar(require("./wallet"), exports);
|
|
25
26
|
__exportStar(require("./constants"), exports);
|
|
26
27
|
__exportStar(require("./types"), exports);
|
|
28
|
+
__exportStar(require("./utils"), exports);
|
package/dist/network.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getNetworkDetails: (input?:
|
|
3
|
-
export declare const getNetworkRpcUrls: (input?:
|
|
4
|
-
export declare const getNetworkDomainDetails: (
|
|
5
|
-
export declare const getNetworkDomainRpcUrls: (
|
|
1
|
+
import type { DomainParams, NetworkParams } from './types/network';
|
|
2
|
+
export declare const getNetworkDetails: (input?: NetworkParams) => import("./types/network").Network;
|
|
3
|
+
export declare const getNetworkRpcUrls: (input?: NetworkParams) => string[];
|
|
4
|
+
export declare const getNetworkDomainDetails: (params: DomainParams) => import("./types/network").Domain;
|
|
5
|
+
export declare const getNetworkDomainRpcUrls: (params: DomainParams) => string[];
|
|
6
6
|
//# sourceMappingURL=network.d.ts.map
|
package/dist/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAElE,eAAO,MAAM,iBAAiB,WAAY,aAAa,sCAWtD,CAAA;AAED,eAAO,MAAM,iBAAiB,WAAY,aAAa,aAOtD,CAAA;AAED,eAAO,MAAM,uBAAuB,WAAY,YAAY,qCAY3D,CAAA;AAED,eAAO,MAAM,uBAAuB,WAAY,YAAY,aAM3D,CAAA"}
|
package/dist/network.js
CHANGED
|
@@ -23,8 +23,8 @@ const getNetworkRpcUrls = (input) => {
|
|
|
23
23
|
return network.rpcUrls;
|
|
24
24
|
};
|
|
25
25
|
exports.getNetworkRpcUrls = getNetworkRpcUrls;
|
|
26
|
-
const getNetworkDomainDetails = (
|
|
27
|
-
const { networkId, domainId } =
|
|
26
|
+
const getNetworkDomainDetails = (params) => {
|
|
27
|
+
const { networkId, domainId } = params;
|
|
28
28
|
// Find the network with the provided id
|
|
29
29
|
const network = (0, exports.getNetworkDetails)({ networkId });
|
|
30
30
|
if (!network)
|
|
@@ -36,9 +36,9 @@ const getNetworkDomainDetails = (input) => {
|
|
|
36
36
|
return domain;
|
|
37
37
|
};
|
|
38
38
|
exports.getNetworkDomainDetails = getNetworkDomainDetails;
|
|
39
|
-
const getNetworkDomainRpcUrls = (
|
|
39
|
+
const getNetworkDomainRpcUrls = (params) => {
|
|
40
40
|
// Get the network details
|
|
41
|
-
const domain = (0, exports.getNetworkDomainDetails)(
|
|
41
|
+
const domain = (0, exports.getNetworkDomainDetails)(params);
|
|
42
42
|
if (!domain.rpcUrls || domain.rpcUrls.length === 0)
|
|
43
43
|
throw new Error(`Domain has no rpcUrls`);
|
|
44
44
|
return domain.rpcUrls;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAC5C,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,YAAY,EAAE,CAAA;AAElD,YAAY,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubmittableExtrinsic, SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
|
2
|
+
import type { Hash } from '@polkadot/types/interfaces';
|
|
3
|
+
import type { ISubmittableResult } from '@polkadot/types/types';
|
|
4
|
+
export type { Hash, ISubmittableResult, SubmittableExtrinsic, SubmittableModuleExtrinsics };
|
|
5
|
+
//# sourceMappingURL=extrinsic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extrinsic.d.ts","sourceRoot":"","sources":["../../src/types/extrinsic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAC5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,YAAY,EAAE,IAAI,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AAExC,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AAExB,YAAY,EAAE,EAAE,EAAE,CAAA"}
|
package/dist/types/index.js
CHANGED
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./event"), exports);
|
|
18
|
+
__exportStar(require("./extrinsic"), exports);
|
|
17
19
|
__exportStar(require("./network"), exports);
|
|
20
|
+
__exportStar(require("./transaction"), exports);
|
|
18
21
|
__exportStar(require("./wallet"), exports);
|
package/dist/types/network.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApiOptions } from '@polkadot/api/types';
|
|
1
2
|
export type Explorer = {
|
|
2
3
|
name: string;
|
|
3
4
|
url: string;
|
|
@@ -16,11 +17,13 @@ export type Network = {
|
|
|
16
17
|
isTestnet?: boolean;
|
|
17
18
|
isLocalhost?: boolean;
|
|
18
19
|
};
|
|
19
|
-
export type
|
|
20
|
+
export type NetworkParams = {
|
|
20
21
|
networkId?: string;
|
|
21
22
|
} | undefined;
|
|
22
|
-
export type
|
|
23
|
+
export type DomainParams = {
|
|
23
24
|
networkId?: string;
|
|
24
25
|
domainId: string;
|
|
25
26
|
};
|
|
27
|
+
export type ActivateParams<T> = T & ApiOptions;
|
|
28
|
+
export type { ApiOptions };
|
|
26
29
|
//# sourceMappingURL=network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/types/network.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/types/network.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,QAAQ,EAAE,CAAA;IACpB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAA;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,UAAU,CAAA;AAE9C,YAAY,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/types/network.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SignerOptions } from '@polkadot/api/types';
|
|
2
|
+
import type { ActionEvents } from '../types/event';
|
|
3
|
+
export type EventsValidated = {
|
|
4
|
+
expected: ActionEvents[];
|
|
5
|
+
found: ActionEvents[];
|
|
6
|
+
};
|
|
7
|
+
export type TransactionSignedAndSend = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
txHash: string | undefined;
|
|
10
|
+
blockHash: string | undefined;
|
|
11
|
+
events: EventsValidated;
|
|
12
|
+
};
|
|
13
|
+
export { SignerOptions };
|
|
14
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,EAAE,eAAe,CAAA;CACxB,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
package/dist/types/wallet.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
import type { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import type { AddressOrPair, Signer, SignerResult } from '@polkadot/api/types';
|
|
3
|
+
import type { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
|
|
4
|
+
import type { KeyringPair } from '@polkadot/keyring/types';
|
|
5
|
+
import type { DomainParams, NetworkParams } from './network';
|
|
1
6
|
export type Mnemonic = {
|
|
2
7
|
mnemonic: string;
|
|
3
8
|
};
|
|
4
9
|
export type URI = {
|
|
5
10
|
uri: string;
|
|
6
11
|
};
|
|
7
|
-
export type
|
|
8
|
-
appName
|
|
12
|
+
export type ExtraActivationOptions = {
|
|
13
|
+
appName?: string;
|
|
14
|
+
api?: ApiPromise;
|
|
9
15
|
};
|
|
10
16
|
export type MnemonicOrURI = Mnemonic | URI;
|
|
17
|
+
export type Wallet = {
|
|
18
|
+
keyringPair?: KeyringPair;
|
|
19
|
+
injectedAccount?: InjectedAccountWithMeta;
|
|
20
|
+
address: string;
|
|
21
|
+
commonAddress: string;
|
|
22
|
+
};
|
|
23
|
+
export interface GeneratedWallet extends Wallet {
|
|
24
|
+
mnemonic: string;
|
|
25
|
+
}
|
|
26
|
+
export type ActivateWalletParams = (NetworkParams | DomainParams) & MnemonicOrURI & ExtraActivationOptions;
|
|
27
|
+
export type WalletActivated = {
|
|
28
|
+
api: ApiPromise;
|
|
29
|
+
accounts: InjectedAccountWithMeta[] & KeyringPair[];
|
|
30
|
+
address: string;
|
|
31
|
+
};
|
|
32
|
+
export type { AddressOrPair, ApiPromise, InjectedAccountWithMeta, KeyringPair, Signer, SignerResult, };
|
|
11
33
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/types/wallet.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/types/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE5D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,GAAG,CAAA;AAE1C,MAAM,MAAM,MAAM,GAAG;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,eAAe,CAAC,EAAE,uBAAuB,CAAA;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,aAAa,GAAG,YAAY,CAAC,GAC/D,aAAa,GACb,sBAAsB,CAAA;AAExB,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,UAAU,CAAA;IACf,QAAQ,EAAE,uBAAuB,EAAE,GAAG,WAAW,EAAE,CAAA;IACnD,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,YAAY,EACV,aAAa,EACb,UAAU,EACV,uBAAuB,EACvB,WAAW,EACX,MAAM,EACN,YAAY,GACb,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createType.d.ts","sourceRoot":"","sources":["../../src/utils/createType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,eAAO,MAAM,mBAAmB,QAAS,UAAU,WAAW,MAAM,eACZ,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAccountIdType = void 0;
|
|
4
|
+
const types_1 = require("@polkadot/types");
|
|
5
|
+
const createAccountIdType = (api, address) => (0, types_1.createType)(api.registry, 'AccountId', address).toU8a();
|
|
6
|
+
exports.createAccountIdType = createAccountIdType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectTxSuccess.d.ts","sourceRoot":"","sources":["../../src/utils/detectTxSuccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGjD,eAAO,MAAM,eAAe,WAAY,WAAW,EAAE,KAAG,OAMvD,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/utils/detectTxSuccess.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.detectTxSuccess = void 0;
|
|
5
|
+
const events_1 = require("./events");
|
|
6
|
+
const detectTxSuccess = (events) => {
|
|
7
|
+
events.forEach(({ event: { method, section } }) => {
|
|
8
|
+
if (events_1.expectSuccessfulTxEvent.indexOf(`${section}.${method}`) > -1)
|
|
9
|
+
return true;
|
|
10
|
+
});
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
exports.detectTxSuccess = detectTxSuccess;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const enum Type {
|
|
2
|
+
system = "system"
|
|
3
|
+
}
|
|
4
|
+
export declare const eventName: (type: Type, event: string) => string;
|
|
5
|
+
export declare const eventsGroup: {
|
|
6
|
+
system: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const expectSuccessfulTxEvent: string[];
|
|
11
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAGA,0BAAkB,IAAI;IACpB,MAAM,WAAW;CAClB;AAGD,eAAO,MAAM,SAAS,SAAU,IAAI,SAAS,MAAM,WAAuB,CAAA;AAY1E,eAAO,MAAM,WAAW;;;;CAEvB,CAAA;AAGD,eAAO,MAAM,uBAAuB,UAAmB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/utils/events.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.expectSuccessfulTxEvent = exports.eventsGroup = exports.eventName = void 0;
|
|
5
|
+
// Utility Function for Event Names
|
|
6
|
+
const eventName = (type, event) => `${type}.${event}`;
|
|
7
|
+
exports.eventName = eventName;
|
|
8
|
+
// System Events
|
|
9
|
+
const system = {
|
|
10
|
+
failure: (0, exports.eventName)("system" /* Type.system */, 'ExtrinsicFailed'),
|
|
11
|
+
newAccount: (0, exports.eventName)("system" /* Type.system */, 'NewAccount'),
|
|
12
|
+
success: (0, exports.eventName)("system" /* Type.system */, 'ExtrinsicSuccess'),
|
|
13
|
+
};
|
|
14
|
+
// Group of Events
|
|
15
|
+
exports.eventsGroup = {
|
|
16
|
+
system,
|
|
17
|
+
};
|
|
18
|
+
// Export a default success event
|
|
19
|
+
exports.expectSuccessfulTxEvent = [system.success];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.u8aToHex = exports.stringToU8a = void 0;
|
|
4
|
+
const util_1 = require("@polkadot/util");
|
|
5
|
+
Object.defineProperty(exports, "stringToU8a", { enumerable: true, get: function () { return util_1.stringToU8a; } });
|
|
6
|
+
Object.defineProperty(exports, "u8aToHex", { enumerable: true, get: function () { return util_1.u8aToHex; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './createType';
|
|
2
|
+
export * from './events';
|
|
3
|
+
export * from './format';
|
|
4
|
+
export * from './ready';
|
|
5
|
+
export * from './sign';
|
|
6
|
+
export * from './signAndSendTx';
|
|
7
|
+
export * from './validateEvents';
|
|
8
|
+
export * from './verify';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createType"), exports);
|
|
18
|
+
__exportStar(require("./events"), exports);
|
|
19
|
+
__exportStar(require("./format"), exports);
|
|
20
|
+
__exportStar(require("./ready"), exports);
|
|
21
|
+
__exportStar(require("./sign"), exports);
|
|
22
|
+
__exportStar(require("./signAndSendTx"), exports);
|
|
23
|
+
__exportStar(require("./validateEvents"), exports);
|
|
24
|
+
__exportStar(require("./verify"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ready.d.ts","sourceRoot":"","sources":["../../src/utils/ready.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cryptoWaitReady = void 0;
|
|
4
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
5
|
+
Object.defineProperty(exports, "cryptoWaitReady", { enumerable: true, get: function () { return util_crypto_1.cryptoWaitReady; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { signatureVerify } from '@polkadot/util-crypto';
|
|
2
|
+
import type { Signer } from '../types/wallet';
|
|
3
|
+
export declare const signMessage: (signer: Signer, address: string, data: string) => Promise<import("@polkadot/types/types/extrinsic").SignerResult>;
|
|
4
|
+
export declare const signingKey: (publicKey: Uint8Array) => `0x${string}`;
|
|
5
|
+
export { signatureVerify };
|
|
6
|
+
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../src/utils/sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG7C,eAAO,MAAM,WAAW,WAAkB,MAAM,WAAW,MAAM,QAAQ,MAAM,oEAQ9E,CAAA;AAED,eAAO,MAAM,UAAU,cAAe,UAAU,kBAAwB,CAAA;AAExE,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.signatureVerify = exports.signingKey = exports.signMessage = void 0;
|
|
13
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
14
|
+
Object.defineProperty(exports, "signatureVerify", { enumerable: true, get: function () { return util_crypto_1.signatureVerify; } });
|
|
15
|
+
const format_1 = require("./format");
|
|
16
|
+
const signMessage = (signer, address, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
if (!signer.signRaw)
|
|
18
|
+
throw new Error('signRaw not available on the signer');
|
|
19
|
+
return yield signer.signRaw({
|
|
20
|
+
address,
|
|
21
|
+
type: 'bytes',
|
|
22
|
+
data,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
exports.signMessage = signMessage;
|
|
26
|
+
const signingKey = (publicKey) => (0, format_1.u8aToHex)(publicKey);
|
|
27
|
+
exports.signingKey = signingKey;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AddressOrPair, Events, ISubmittableResult, SignerOptions, SubmittableExtrinsic, TransactionSignedAndSend } from '../types';
|
|
2
|
+
export declare const signAndSendTx: (sender: AddressOrPair, tx: SubmittableExtrinsic<'promise', ISubmittableResult>, options?: Partial<SignerOptions>, eventsExpected?: Events, log?: boolean) => Promise<TransactionSignedAndSend>;
|
|
3
|
+
//# sourceMappingURL=signAndSendTx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signAndSendTx.d.ts","sourceRoot":"","sources":["../../src/utils/signAndSendTx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,MAAM,EAEN,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,UAAU,CAAA;AAKjB,eAAO,MAAM,aAAa,WAChB,aAAa,MACjB,qBAAqB,SAAS,EAAE,kBAAkB,CAAC,YAC9C,QAAQ,aAAa,CAAC,mBACf,MAAM,QACjB,OAAO,KACX,QAAQ,wBAAwB,CAgClC,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/utils/signAndSendTx.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.signAndSendTx = void 0;
|
|
14
|
+
const detectTxSuccess_1 = require("./detectTxSuccess");
|
|
15
|
+
const events_1 = require("./events");
|
|
16
|
+
const validateEvents_1 = require("./validateEvents");
|
|
17
|
+
const signAndSendTx = (sender_1, tx_1, ...args_1) => __awaiter(void 0, [sender_1, tx_1, ...args_1], void 0, function* (sender, tx, options = {}, eventsExpected = events_1.expectSuccessfulTxEvent, log = false) {
|
|
18
|
+
let success = false;
|
|
19
|
+
let txHashHex = undefined;
|
|
20
|
+
let blockHash = undefined;
|
|
21
|
+
let eventsValidated = { expected: [], found: [] };
|
|
22
|
+
yield new Promise((resolve, reject) => {
|
|
23
|
+
tx.signAndSend(sender, options, ({ events, status, txHash }) => {
|
|
24
|
+
if (status.isInBlock) {
|
|
25
|
+
txHashHex = txHash.toHex();
|
|
26
|
+
blockHash = status.asInBlock.toHex();
|
|
27
|
+
if (log)
|
|
28
|
+
console.log('Successful tx', txHashHex, 'in block', blockHash);
|
|
29
|
+
success = (0, detectTxSuccess_1.detectTxSuccess)(events);
|
|
30
|
+
if (eventsExpected.length > 0) {
|
|
31
|
+
const _events = (0, validateEvents_1.validateEvents)(events, eventsExpected, txHashHex, blockHash, log);
|
|
32
|
+
if (_events.expected.length === 0)
|
|
33
|
+
resolve();
|
|
34
|
+
else
|
|
35
|
+
reject(new Error('Events not found'));
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
resolve();
|
|
39
|
+
}
|
|
40
|
+
else if (status.isRetracted ||
|
|
41
|
+
status.isFinalityTimeout ||
|
|
42
|
+
status.isDropped ||
|
|
43
|
+
status.isInvalid) {
|
|
44
|
+
if (log)
|
|
45
|
+
console.error('Transaction failed');
|
|
46
|
+
reject(new Error('Transaction failed'));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return { success, txHash: txHashHex, blockHash, events: eventsValidated };
|
|
51
|
+
});
|
|
52
|
+
exports.signAndSendTx = signAndSendTx;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EventRecord, Events, EventsValidated } from '../types';
|
|
2
|
+
export declare const validateEvents: (events: EventRecord[], eventsExpected: Events | undefined, tx: string, block: string, log?: boolean) => EventsValidated;
|
|
3
|
+
//# sourceMappingURL=validateEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateEvents.d.ts","sourceRoot":"","sources":["../../src/utils/validateEvents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAGpE,eAAO,MAAM,cAAc,WACjB,WAAW,EAAE,0CAEjB,MAAM,SACH,MAAM,QACR,OAAO,KACX,eAmBF,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/utils/validateEvents.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.validateEvents = void 0;
|
|
5
|
+
const events_1 = require("./events");
|
|
6
|
+
const validateEvents = (events, eventsExpected = events_1.expectSuccessfulTxEvent, tx, block, log = false) => {
|
|
7
|
+
const _eventsExpected = typeof eventsExpected === 'string'
|
|
8
|
+
? [eventsExpected]
|
|
9
|
+
: eventsExpected.map((e) => (typeof e === 'string' ? [e] : e)).flat();
|
|
10
|
+
const found = [];
|
|
11
|
+
events.forEach(({ event: { data, method, section } }) => {
|
|
12
|
+
const index = _eventsExpected.indexOf(`${section}.${method}`);
|
|
13
|
+
if (index > -1) {
|
|
14
|
+
_eventsExpected.splice(index, 1);
|
|
15
|
+
found.push(`${section}.${method}`);
|
|
16
|
+
}
|
|
17
|
+
else if (log)
|
|
18
|
+
console.log('Event not expected', `${section}.${method}`, 'tx', tx, 'block', block);
|
|
19
|
+
});
|
|
20
|
+
if (_eventsExpected.length > 0)
|
|
21
|
+
console.log('Events not found', _eventsExpected, 'tx', tx, 'block', block);
|
|
22
|
+
return { expected: _eventsExpected, found };
|
|
23
|
+
};
|
|
24
|
+
exports.validateEvents = validateEvents;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/utils/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isHex = exports.isAddress = void 0;
|
|
4
|
+
const util_1 = require("@polkadot/util");
|
|
5
|
+
Object.defineProperty(exports, "isHex", { enumerable: true, get: function () { return util_1.isHex; } });
|
|
6
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
7
|
+
Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return util_crypto_1.isAddress; } });
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
export
|
|
7
|
-
export type WalletActivated = {
|
|
8
|
-
api: ApiPromise;
|
|
9
|
-
accounts: InjectedAccountWithMeta[] & KeyringPair[];
|
|
10
|
-
};
|
|
11
|
-
export declare const activateWallet: (input: ActivateWalletInput) => Promise<WalletActivated>;
|
|
12
|
-
export declare const mockWallets: (network?: NetworkInput | DomainInput) => Promise<WalletActivated[]>;
|
|
1
|
+
import type { DomainParams, MnemonicOrURI, NetworkParams } from './types';
|
|
2
|
+
import type { ActivateWalletParams, ApiPromise, GeneratedWallet, Wallet, WalletActivated } from './types/wallet';
|
|
3
|
+
export declare const setupWallet: (params: MnemonicOrURI) => Wallet;
|
|
4
|
+
export declare const generateWallet: () => GeneratedWallet;
|
|
5
|
+
export declare const activateWallet: (params: ActivateWalletParams) => Promise<WalletActivated>;
|
|
6
|
+
export declare const mockWallets: (network?: NetworkParams | DomainParams, api?: ApiPromise) => Promise<WalletActivated[]>;
|
|
13
7
|
export declare const getMockWallet: (name: string, wallets: WalletActivated[]) => WalletActivated;
|
|
14
8
|
//# sourceMappingURL=wallet.d.ts.map
|
package/dist/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAY,aAAa,EAAE,aAAa,EAAO,MAAM,SAAS,CAAA;AACxF,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,MAAM,EACN,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAEvB,eAAO,MAAM,WAAW,WAAY,aAAa,KAAG,MAiBnD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,eAUjC,CAAA;AAED,eAAO,MAAM,cAAc,WAAkB,oBAAoB,KAAG,QAAQ,eAAe,CA4B1F,CAAA;AAED,eAAO,MAAM,WAAW,aACb,aAAa,GAAG,YAAY,QAC/B,UAAU,KACf,QAAQ,eAAe,EAAE,CAW3B,CAAA;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,WAAW,eAAe,EAAE,KAAG,eAClB,CAAA"}
|
package/dist/wallet.js
CHANGED
|
@@ -33,44 +33,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getMockWallet = exports.mockWallets = exports.activateWallet = exports.setupWallet = void 0;
|
|
36
|
+
exports.getMockWallet = exports.mockWallets = exports.activateWallet = exports.generateWallet = exports.setupWallet = void 0;
|
|
37
37
|
const api_1 = require("@polkadot/api");
|
|
38
38
|
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
39
|
+
const address_1 = require("./address");
|
|
39
40
|
const api_2 = require("./api");
|
|
40
41
|
const network_1 = require("./constants/network");
|
|
41
42
|
const wallet_1 = require("./constants/wallet");
|
|
42
|
-
const setupWallet = (
|
|
43
|
-
yield (0, util_crypto_1.cryptoWaitReady)();
|
|
43
|
+
const setupWallet = (params) => {
|
|
44
44
|
const keyring = new api_1.Keyring({ type: 'sr25519' });
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
45
|
+
let keyringPair;
|
|
46
|
+
if (params.uri) {
|
|
47
47
|
// Treat as uri
|
|
48
|
-
|
|
48
|
+
keyringPair = keyring.addFromUri(params.uri);
|
|
49
49
|
}
|
|
50
|
-
else if (
|
|
50
|
+
else if (params.mnemonic) {
|
|
51
51
|
// Treat as mnemonic
|
|
52
|
-
|
|
52
|
+
keyringPair = keyring.addFromUri(params.mnemonic);
|
|
53
53
|
}
|
|
54
54
|
else
|
|
55
55
|
throw new Error('Invalid mnemonic or private key');
|
|
56
|
-
return
|
|
57
|
-
|
|
56
|
+
return {
|
|
57
|
+
keyringPair,
|
|
58
|
+
address: (0, address_1.address)(keyringPair.address),
|
|
59
|
+
commonAddress: keyringPair.address,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
58
62
|
exports.setupWallet = setupWallet;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const generateWallet = () => {
|
|
64
|
+
const mnemonic = (0, util_crypto_1.mnemonicGenerate)();
|
|
65
|
+
const { keyringPair, address, commonAddress } = (0, exports.setupWallet)({ mnemonic });
|
|
66
|
+
return {
|
|
67
|
+
mnemonic,
|
|
68
|
+
keyringPair,
|
|
69
|
+
address,
|
|
70
|
+
commonAddress,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.generateWallet = generateWallet;
|
|
74
|
+
const activateWallet = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
if (!params.api) {
|
|
76
|
+
// Create the API instance if not provided
|
|
77
|
+
params.api =
|
|
78
|
+
params.domainId === undefined
|
|
79
|
+
? yield (0, api_2.activate)(params)
|
|
80
|
+
: yield (0, api_2.activateDomain)(params);
|
|
81
|
+
}
|
|
64
82
|
const accounts = [];
|
|
65
|
-
if (
|
|
83
|
+
if (params.mnemonic || params.uri) {
|
|
66
84
|
// Attach the wallet in a node environment
|
|
67
|
-
const
|
|
68
|
-
|
|
85
|
+
const { keyringPair } = (0, exports.setupWallet)(params);
|
|
86
|
+
if (keyringPair)
|
|
87
|
+
accounts.push(keyringPair);
|
|
69
88
|
}
|
|
70
89
|
else if (typeof window !== 'undefined') {
|
|
71
90
|
const { web3Enable, web3Accounts } = yield Promise.resolve().then(() => __importStar(require('@polkadot/extension-dapp')));
|
|
72
91
|
// Enable Polkadot.js extension in the browser
|
|
73
|
-
yield web3Enable(
|
|
92
|
+
yield web3Enable(params.appName || 'Auto');
|
|
74
93
|
// Get the list of accounts from the extension
|
|
75
94
|
const allAccounts = yield web3Accounts();
|
|
76
95
|
accounts.push(...allAccounts);
|
|
@@ -79,11 +98,17 @@ const activateWallet = (input) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
79
98
|
}
|
|
80
99
|
else
|
|
81
100
|
throw new Error('No wallet provided');
|
|
82
|
-
return { api, accounts };
|
|
101
|
+
return { api: params.api, accounts, address: (0, address_1.address)(accounts[0].address) };
|
|
83
102
|
});
|
|
84
103
|
exports.activateWallet = activateWallet;
|
|
85
|
-
const mockWallets = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (network = { networkId: network_1.defaultNetwork.id }) {
|
|
86
|
-
|
|
104
|
+
const mockWallets = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (network = { networkId: network_1.defaultNetwork.id }, api) {
|
|
105
|
+
const wallets = [];
|
|
106
|
+
for (const uri of wallet_1.mockURIs) {
|
|
107
|
+
const wallet = yield (0, exports.activateWallet)(Object.assign(Object.assign({}, network), { uri,
|
|
108
|
+
api }));
|
|
109
|
+
wallets.push(wallet);
|
|
110
|
+
}
|
|
111
|
+
return wallets;
|
|
87
112
|
});
|
|
88
113
|
exports.mockWallets = mockWallets;
|
|
89
114
|
const getMockWallet = (name, wallets) => wallets[Object.values(wallet_1.mockURIs).indexOf(`//${name}`)];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6-devnet-support",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"browser": {
|
|
37
37
|
"fs": false
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ff53a35cb89e0979f528e0acb055f0b0ba516bcd"
|
|
40
40
|
}
|
package/dist/types/api.d.ts
DELETED
package/dist/types/api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAErE,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAA"}
|
|
File without changes
|