@autonomys/auto-consensus 0.1.3 → 0.1.5
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 +31 -31
- package/dist/balances.d.ts +1 -1
- package/dist/balances.d.ts.map +1 -1
- package/dist/batch.d.ts +2 -2
- package/dist/batch.d.ts.map +1 -1
- package/dist/batch.js +1 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/info.d.ts +6 -1
- package/dist/info.d.ts.map +1 -1
- package/dist/info.js +20 -8
- package/dist/remark.d.ts +2 -2
- package/dist/remark.d.ts.map +1 -1
- package/dist/remark.js +1 -10
- package/dist/staking.d.ts +11 -12
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +27 -29
- package/dist/transfer.d.ts +3 -3
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +7 -16
- package/dist/types/transaction.d.ts +3 -3
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist/utils/detectTxSuccess.d.ts +1 -1
- package/dist/utils/detectTxSuccess.d.ts.map +1 -1
- package/dist/utils/query.d.ts +2 -0
- package/dist/utils/query.d.ts.map +1 -0
- package/dist/utils/query.js +34 -0
- package/dist/utils/signAndSendTx.d.ts +1 -2
- package/dist/utils/signAndSendTx.d.ts.map +1 -1
- package/dist/utils/sudo.d.ts +1 -3
- package/dist/utils/sudo.d.ts.map +1 -1
- package/dist/utils/validateEvents.d.ts +1 -1
- package/dist/utils/validateEvents.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- package/dist/address.js +0 -7
package/README.md
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# Autonomys Auto Consensus SDK
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Autonomys Auto Consensus SDK provides functionalities for blockchain consensus interactions, including address management, balance retrieval, staking, and transfers.
|
|
6
|
-
|
|
7
|
-
## Address Management
|
|
8
|
-
|
|
9
|
-
- `generateAddress(
|
|
10
|
-
|
|
11
|
-
## Balances
|
|
12
|
-
|
|
13
|
-
- `getBalance(address: string): Promise<Balance>`: Retrieves the balance of an address.
|
|
14
|
-
|
|
15
|
-
## Staking
|
|
16
|
-
|
|
17
|
-
- `stake(address: string, amount: number): Promise<void>`: Stakes an amount from an address.
|
|
18
|
-
|
|
19
|
-
## Transfers
|
|
20
|
-
|
|
21
|
-
- `transfer(from: string, to: string, amount: number): Promise<void>`: Transfers an amount from one address to another.
|
|
22
|
-
|
|
23
|
-
## Info
|
|
24
|
-
|
|
25
|
-
- `getInfo(): Promise<Info>`: Retrieves blockchain information.
|
|
26
|
-
|
|
27
|
-
## Import Example
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { generateAddress, getBalance, stake, transfer, getInfo } from '@autonomys/auto-consensus'
|
|
31
|
-
```
|
|
1
|
+
# Autonomys Auto Consensus SDK
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Autonomys Auto Consensus SDK provides functionalities for blockchain consensus interactions, including address management, balance retrieval, staking, and transfers.
|
|
6
|
+
|
|
7
|
+
## Address Management
|
|
8
|
+
|
|
9
|
+
- `generateAddress(params: MnemonicOrURI): string`: Generates a new address.
|
|
10
|
+
|
|
11
|
+
## Balances
|
|
12
|
+
|
|
13
|
+
- `getBalance(address: string): Promise<Balance>`: Retrieves the balance of an address.
|
|
14
|
+
|
|
15
|
+
## Staking
|
|
16
|
+
|
|
17
|
+
- `stake(address: string, amount: number): Promise<void>`: Stakes an amount from an address.
|
|
18
|
+
|
|
19
|
+
## Transfers
|
|
20
|
+
|
|
21
|
+
- `transfer(from: string, to: string, amount: number): Promise<void>`: Transfers an amount from one address to another.
|
|
22
|
+
|
|
23
|
+
## Info
|
|
24
|
+
|
|
25
|
+
- `getInfo(): Promise<Info>`: Retrieves blockchain information.
|
|
26
|
+
|
|
27
|
+
## Import Example
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { generateAddress, getBalance, stake, transfer, getInfo } from '@autonomys/auto-consensus'
|
|
31
|
+
```
|
package/dist/balances.d.ts
CHANGED
package/dist/balances.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../src/balances.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../src/balances.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAM,MAAM,uBAAuB,CAAA;AAS3D,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,aAAa,eAAsB,MAAM,yDAQrD,CAAA;AAED,eAAO,MAAM,OAAO,QAAe,UAAU,WAAW,MAAM,KAAG,QAAQ,WAAW,CAgBnF,CAAA"}
|
package/dist/batch.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ApiPromise } from '@
|
|
2
|
-
export declare const batch: (api: ApiPromise, txs: any[]) =>
|
|
1
|
+
import type { ApiPromise } from '@autonomys/auto-utils';
|
|
2
|
+
export declare const batch: (api: ApiPromise, txs: any[]) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
3
3
|
//# sourceMappingURL=batch.d.ts.map
|
package/dist/batch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,QAAS,UAAU,OAAO,GAAG,EAAE,wHAA8B,CAAA"}
|
package/dist/batch.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.batch = void 0;
|
|
13
|
-
const batch = (api, txs) =>
|
|
4
|
+
const batch = (api, txs) => api.tx.utility.batch(txs);
|
|
14
5
|
exports.batch = batch;
|
package/dist/index.d.ts
CHANGED
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAE1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ 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);
|
|
19
18
|
__exportStar(require("./balances"), exports);
|
|
20
19
|
__exportStar(require("./batch"), exports);
|
|
21
20
|
__exportStar(require("./info"), exports);
|
package/dist/info.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const rpc: (methodPath: string, params?: any[], networkId?: string) => Promise<any>;
|
|
2
|
+
export declare const query: (methodPath: string, params?: any[], networkId?: string) => Promise<any>;
|
|
3
|
+
export declare const block: (networkId?: string) => Promise<any>;
|
|
4
|
+
export declare const blockNumber: (networkId?: string) => Promise<number>;
|
|
5
|
+
export declare const blockHash: (networkId?: string) => Promise<any>;
|
|
6
|
+
export declare const networkTimestamp: (networkId?: string) => Promise<any>;
|
|
2
7
|
//# sourceMappingURL=info.d.ts.map
|
package/dist/info.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG,eAAsB,MAAM,WAAU,GAAG,EAAE,cAAmB,MAAM,iBACrB,CAAA;AAE/D,eAAO,MAAM,KAAK,eAAsB,MAAM,WAAU,GAAG,EAAE,cAAmB,MAAM,iBACrB,CAAA;AAEjE,eAAO,MAAM,KAAK,eAAsB,MAAM,iBAA+C,CAAA;AAE7F,eAAO,MAAM,WAAW,eAAsB,MAAM,KAAG,QAAQ,MAAM,CAKpE,CAAA;AAED,eAAO,MAAM,SAAS,eAAsB,MAAM,iBAKjD,CAAA;AAED,eAAO,MAAM,gBAAgB,eAAsB,MAAM,iBACZ,CAAA"}
|
package/dist/info.js
CHANGED
|
@@ -10,13 +10,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.networkTimestamp = void 0;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
exports.networkTimestamp = exports.blockHash = exports.blockNumber = exports.block = exports.query = exports.rpc = void 0;
|
|
14
|
+
const query_1 = require("./utils/query");
|
|
15
|
+
const rpc = (methodPath_1, ...args_1) => __awaiter(void 0, [methodPath_1, ...args_1], void 0, function* (methodPath, params = [], networkId) { return yield (0, query_1.queryMethodPath)(`rpc.${methodPath}`, params, networkId); });
|
|
16
|
+
exports.rpc = rpc;
|
|
17
|
+
const query = (methodPath_2, ...args_2) => __awaiter(void 0, [methodPath_2, ...args_2], void 0, function* (methodPath, params = [], networkId) { return yield (0, query_1.queryMethodPath)(`query.${methodPath}`, params, networkId); });
|
|
18
|
+
exports.query = query;
|
|
19
|
+
const block = (networkId) => __awaiter(void 0, void 0, void 0, function* () { return yield (0, exports.rpc)('chain.getBlock', [], networkId); });
|
|
20
|
+
exports.block = block;
|
|
21
|
+
const blockNumber = (networkId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
// Get the block
|
|
23
|
+
const _block = yield (0, exports.block)(networkId);
|
|
24
|
+
return _block.block.header.number.toNumber();
|
|
21
25
|
});
|
|
26
|
+
exports.blockNumber = blockNumber;
|
|
27
|
+
const blockHash = (networkId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
// Get the block
|
|
29
|
+
const _block = yield (0, exports.block)(networkId);
|
|
30
|
+
return _block.block.header.hash.toString();
|
|
31
|
+
});
|
|
32
|
+
exports.blockHash = blockHash;
|
|
33
|
+
const networkTimestamp = (networkId) => __awaiter(void 0, void 0, void 0, function* () { return yield (0, exports.query)('timestamp.now', [], networkId); });
|
|
22
34
|
exports.networkTimestamp = networkTimestamp;
|
package/dist/remark.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ApiPromise } from '@
|
|
2
|
-
export declare const remark: (api: ApiPromise, remark: string, withEvent?: boolean) =>
|
|
1
|
+
import type { ApiPromise } from '@autonomys/auto-utils';
|
|
2
|
+
export declare const remark: (api: ApiPromise, remark: string, withEvent?: boolean) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
3
3
|
//# sourceMappingURL=remark.d.ts.map
|
package/dist/remark.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark.d.ts","sourceRoot":"","sources":["../src/remark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"remark.d.ts","sourceRoot":"","sources":["../src/remark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,MAAM,QAAS,UAAU,UAAU,MAAM,cAAc,OAAO,wHACQ,CAAA"}
|
package/dist/remark.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.remark = void 0;
|
|
13
|
-
const remark = (api, remark, withEvent) =>
|
|
4
|
+
const remark = (api, remark, withEvent) => !withEvent ? api.tx.system.remark(remark) : api.tx.system.remarkWithEvent(remark);
|
|
14
5
|
exports.remark = remark;
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ApiPromise } from '@
|
|
2
|
-
import type { KeyringPair } from '@polkadot/keyring/types';
|
|
1
|
+
import type { ApiPromise, KeyringPair } from '@autonomys/auto-utils';
|
|
3
2
|
export type OperatorDetails = {
|
|
4
3
|
signingKey: string;
|
|
5
4
|
currentDomainId: bigint;
|
|
@@ -19,7 +18,7 @@ export type Operator = {
|
|
|
19
18
|
operatorDetails: OperatorDetails;
|
|
20
19
|
};
|
|
21
20
|
type StringNumberOrBigInt = string | number | bigint;
|
|
22
|
-
export type
|
|
21
|
+
export type RegisterOperatorParams = {
|
|
23
22
|
api: ApiPromise;
|
|
24
23
|
senderAddress: string;
|
|
25
24
|
Operator: KeyringPair;
|
|
@@ -28,23 +27,23 @@ export type RegisterOperatorInput = {
|
|
|
28
27
|
minimumNominatorStake: StringNumberOrBigInt;
|
|
29
28
|
nominationTax: StringNumberOrBigInt;
|
|
30
29
|
};
|
|
31
|
-
export type
|
|
30
|
+
export type StakingParams = {
|
|
32
31
|
api: ApiPromise;
|
|
33
32
|
operatorId: StringNumberOrBigInt;
|
|
34
33
|
};
|
|
35
|
-
export interface
|
|
34
|
+
export interface WithdrawStakeParams extends StakingParams {
|
|
36
35
|
shares: StringNumberOrBigInt;
|
|
37
36
|
}
|
|
38
|
-
export interface
|
|
37
|
+
export interface NominateOperatorParams extends StakingParams {
|
|
39
38
|
amountToStake: StringNumberOrBigInt;
|
|
40
39
|
}
|
|
41
40
|
export declare const operators: (api: ApiPromise) => Promise<Operator[]>;
|
|
42
41
|
export declare const operator: (api: ApiPromise, operatorId: StringNumberOrBigInt) => Promise<OperatorDetails>;
|
|
43
|
-
export declare const registerOperator: (
|
|
44
|
-
export declare const nominateOperator: (
|
|
45
|
-
export declare const withdrawStake: (
|
|
46
|
-
export declare const deregisterOperator: (
|
|
47
|
-
export declare const unlockFunds: (
|
|
48
|
-
export declare const unlockNominator: (
|
|
42
|
+
export declare const registerOperator: (params: RegisterOperatorParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
43
|
+
export declare const nominateOperator: (params: NominateOperatorParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
44
|
+
export declare const withdrawStake: (params: WithdrawStakeParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
45
|
+
export declare const deregisterOperator: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
46
|
+
export declare const unlockFunds: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
47
|
+
export declare const unlockNominator: (params: StakingParams) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
49
48
|
export {};
|
|
50
49
|
//# sourceMappingURL=staking.d.ts.map
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAoBpE,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,sBAAsB,EAAE,MAAM,CAAA;CAC/B,CAAA;AACD,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,eAAe,CAAA;CACjC,CAAA;AAED,KAAK,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAEpD,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,UAAU,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,aAAa,EAAE,oBAAoB,CAAA;IACnC,qBAAqB,EAAE,oBAAoB,CAAA;IAC3C,aAAa,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,UAAU,CAAA;IACf,UAAU,EAAE,oBAAoB,CAAA;CACjC,CAAA;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,aAAa,EAAE,oBAAoB,CAAA;CACpC;AA8BD,eAAO,MAAM,SAAS,QAAe,UAAU,wBAQ9C,CAAA;AAED,eAAO,MAAM,QAAQ,QAAe,UAAU,cAAc,oBAAoB,6BAQ/E,CAAA;AAED,eAAO,MAAM,gBAAgB,WAAY,sBAAsB,wHA6B9D,CAAA;AAED,eAAO,MAAM,gBAAgB,WAAY,sBAAsB,wHAS9D,CAAA;AAED,eAAO,MAAM,aAAa,WAAY,mBAAmB,wHASxD,CAAA;AAED,eAAO,MAAM,kBAAkB,WAAY,aAAa,wHASvD,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,aAAa,wHAShD,CAAA;AAED,eAAO,MAAM,eAAe,WAAY,aAAa,wHASpD,CAAA"}
|
package/dist/staking.js
CHANGED
|
@@ -11,8 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.unlockNominator = exports.unlockFunds = exports.deregisterOperator = exports.withdrawStake = exports.nominateOperator = exports.registerOperator = exports.operator = exports.operators = void 0;
|
|
14
|
-
const
|
|
15
|
-
const util_1 = require("@polkadot/util");
|
|
14
|
+
const auto_utils_1 = require("@autonomys/auto-utils");
|
|
16
15
|
const parseOperatorDetails = (operatorDetails) => {
|
|
17
16
|
const rawOD = operatorDetails.toJSON();
|
|
18
17
|
return {
|
|
@@ -59,14 +58,13 @@ const operator = (api, operatorId) => __awaiter(void 0, void 0, void 0, function
|
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
60
|
exports.operator = operator;
|
|
62
|
-
const registerOperator = (
|
|
61
|
+
const registerOperator = (params) => {
|
|
63
62
|
try {
|
|
64
|
-
const { api, senderAddress, Operator, domainId, amountToStake, minimumNominatorStake, nominationTax, } =
|
|
65
|
-
const message = (0,
|
|
66
|
-
const signingKey = (0, util_1.u8aToHex)(Operator.publicKey);
|
|
63
|
+
const { api, senderAddress, Operator, domainId, amountToStake, minimumNominatorStake, nominationTax, } = params;
|
|
64
|
+
const message = (0, auto_utils_1.createAccountIdType)(api, senderAddress);
|
|
67
65
|
const signature = Operator.sign(message);
|
|
68
|
-
return
|
|
69
|
-
signingKey,
|
|
66
|
+
return api.tx.domains.registerOperator(parseString(domainId), parseString(amountToStake), {
|
|
67
|
+
signingKey: (0, auto_utils_1.signingKey)(Operator.publicKey),
|
|
70
68
|
minimumNominatorStake: parseString(minimumNominatorStake),
|
|
71
69
|
nominationTax: parseString(nominationTax),
|
|
72
70
|
}, signature);
|
|
@@ -75,60 +73,60 @@ const registerOperator = (input) => __awaiter(void 0, void 0, void 0, function*
|
|
|
75
73
|
console.error('error', error);
|
|
76
74
|
throw new Error('Error creating register operator tx.' + error);
|
|
77
75
|
}
|
|
78
|
-
}
|
|
76
|
+
};
|
|
79
77
|
exports.registerOperator = registerOperator;
|
|
80
|
-
const nominateOperator = (
|
|
78
|
+
const nominateOperator = (params) => {
|
|
81
79
|
try {
|
|
82
|
-
const { api, operatorId, amountToStake } =
|
|
83
|
-
return
|
|
80
|
+
const { api, operatorId, amountToStake } = params;
|
|
81
|
+
return api.tx.domains.nominateOperator(parseString(operatorId), parseString(amountToStake));
|
|
84
82
|
}
|
|
85
83
|
catch (error) {
|
|
86
84
|
console.error('error', error);
|
|
87
85
|
throw new Error('Error creating nominate operator tx.' + error);
|
|
88
86
|
}
|
|
89
|
-
}
|
|
87
|
+
};
|
|
90
88
|
exports.nominateOperator = nominateOperator;
|
|
91
|
-
const withdrawStake = (
|
|
89
|
+
const withdrawStake = (params) => {
|
|
92
90
|
try {
|
|
93
|
-
const { api, operatorId, shares } =
|
|
94
|
-
return
|
|
91
|
+
const { api, operatorId, shares } = params;
|
|
92
|
+
return api.tx.domains.withdrawStake(parseString(operatorId), parseString(shares));
|
|
95
93
|
}
|
|
96
94
|
catch (error) {
|
|
97
95
|
console.error('error', error);
|
|
98
96
|
throw new Error('Error creating withdraw stake tx.' + error);
|
|
99
97
|
}
|
|
100
|
-
}
|
|
98
|
+
};
|
|
101
99
|
exports.withdrawStake = withdrawStake;
|
|
102
|
-
const deregisterOperator = (
|
|
100
|
+
const deregisterOperator = (params) => {
|
|
103
101
|
try {
|
|
104
|
-
const { api, operatorId } =
|
|
105
|
-
return
|
|
102
|
+
const { api, operatorId } = params;
|
|
103
|
+
return api.tx.domains.deregisterOperator(parseString(operatorId));
|
|
106
104
|
}
|
|
107
105
|
catch (error) {
|
|
108
106
|
console.error('error', error);
|
|
109
107
|
throw new Error('Error creating de-register operator tx.' + error);
|
|
110
108
|
}
|
|
111
|
-
}
|
|
109
|
+
};
|
|
112
110
|
exports.deregisterOperator = deregisterOperator;
|
|
113
|
-
const unlockFunds = (
|
|
111
|
+
const unlockFunds = (params) => {
|
|
114
112
|
try {
|
|
115
|
-
const { api, operatorId } =
|
|
116
|
-
return
|
|
113
|
+
const { api, operatorId } = params;
|
|
114
|
+
return api.tx.domains.unlockFunds(parseString(operatorId));
|
|
117
115
|
}
|
|
118
116
|
catch (error) {
|
|
119
117
|
console.error('error', error);
|
|
120
118
|
throw new Error('Error creating unlock funds tx.' + error);
|
|
121
119
|
}
|
|
122
|
-
}
|
|
120
|
+
};
|
|
123
121
|
exports.unlockFunds = unlockFunds;
|
|
124
|
-
const unlockNominator = (
|
|
122
|
+
const unlockNominator = (params) => {
|
|
125
123
|
try {
|
|
126
|
-
const { api, operatorId } =
|
|
127
|
-
return
|
|
124
|
+
const { api, operatorId } = params;
|
|
125
|
+
return api.tx.domains.unlockNominator(parseString(operatorId));
|
|
128
126
|
}
|
|
129
127
|
catch (error) {
|
|
130
128
|
console.error('error', error);
|
|
131
129
|
throw new Error('Error creating unlock nominator tx.' + error);
|
|
132
130
|
}
|
|
133
|
-
}
|
|
131
|
+
};
|
|
134
132
|
exports.unlockNominator = unlockNominator;
|
package/dist/transfer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ApiPromise } from '@
|
|
1
|
+
import type { ApiPromise } from '@autonomys/auto-utils';
|
|
2
2
|
export type Amount = BigInt | number | string;
|
|
3
|
-
export declare const transfer: (api: ApiPromise, receiver: string, amount: Amount, allowDeath?: boolean) =>
|
|
4
|
-
export declare const transferAll: (api: ApiPromise, receiver: string, keepAlive?: boolean) =>
|
|
3
|
+
export declare const transfer: (api: ApiPromise, receiver: string, amount: Amount, allowDeath?: boolean) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
4
|
+
export declare const transferAll: (api: ApiPromise, receiver: string, keepAlive?: boolean) => import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>;
|
|
5
5
|
//# sourceMappingURL=transfer.d.ts.map
|
package/dist/transfer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE7C,eAAO,MAAM,QAAQ,QACd,UAAU,YACL,MAAM,UACR,MAAM,eACD,OAAO,wHAMrB,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,UAAU,YAAY,MAAM,cAAa,OAAO,wHAGhF,CAAA"}
|
package/dist/transfer.js
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// file: src/transfer.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
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
4
|
exports.transferAll = exports.transfer = void 0;
|
|
14
|
-
const transfer = (api, receiver, amount, allowDeath) =>
|
|
5
|
+
const transfer = (api, receiver, amount, allowDeath) => {
|
|
15
6
|
// Transfer the tokens
|
|
16
7
|
return !allowDeath
|
|
17
|
-
?
|
|
18
|
-
:
|
|
19
|
-
}
|
|
8
|
+
? api.tx.balances.transferKeepAlive(receiver, amount)
|
|
9
|
+
: api.tx.balances.transferAllowDeath(receiver, amount);
|
|
10
|
+
};
|
|
20
11
|
exports.transfer = transfer;
|
|
21
|
-
const transferAll = (
|
|
12
|
+
const transferAll = (api, receiver, keepAlive = false) => {
|
|
22
13
|
// Transfer all the tokens
|
|
23
|
-
return
|
|
24
|
-
}
|
|
14
|
+
return api.tx.balances.transferAll(receiver, keepAlive);
|
|
15
|
+
};
|
|
25
16
|
exports.transferAll = transferAll;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActionEvents } from '../types/events';
|
|
2
2
|
export type EventsValidated = {
|
|
3
|
-
expected:
|
|
4
|
-
found:
|
|
3
|
+
expected: ActionEvents[];
|
|
4
|
+
found: ActionEvents[];
|
|
5
5
|
};
|
|
6
6
|
export type TransactionSignedAndSend = {
|
|
7
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectTxSuccess.d.ts","sourceRoot":"","sources":["../../src/utils/detectTxSuccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"detectTxSuccess.d.ts","sourceRoot":"","sources":["../../src/utils/detectTxSuccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,eAAO,MAAM,eAAe,WAAY,WAAW,EAAE,KAAG,OAMvD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/utils/query.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,eACd,MAAM,WACV,GAAG,EAAE,cACD,MAAM,iBAuBnB,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.queryMethodPath = void 0;
|
|
13
|
+
const auto_utils_1 = require("@autonomys/auto-utils");
|
|
14
|
+
const queryMethodPath = (methodPath_1, ...args_1) => __awaiter(void 0, [methodPath_1, ...args_1], void 0, function* (methodPath, params = [], networkId) {
|
|
15
|
+
try {
|
|
16
|
+
const api = yield (0, auto_utils_1.activate)({ networkId });
|
|
17
|
+
// Split the method path to traverse the api object
|
|
18
|
+
const methodParts = methodPath.split('.');
|
|
19
|
+
let method = api;
|
|
20
|
+
for (const part of methodParts) {
|
|
21
|
+
method = method[part];
|
|
22
|
+
}
|
|
23
|
+
if (typeof method !== 'function')
|
|
24
|
+
throw new Error(`Invalid method path: ${methodPath}`);
|
|
25
|
+
const result = yield method(...params);
|
|
26
|
+
yield (0, auto_utils_1.disconnect)(api);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
throw new Error(`Error querying method path: ${methodPath}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.queryMethodPath = queryMethodPath;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AddressOrPair, SubmittableExtrinsic } from '@
|
|
2
|
-
import type { ISubmittableResult } from '@polkadot/types/types';
|
|
1
|
+
import type { AddressOrPair, ISubmittableResult, SubmittableExtrinsic } from '@autonomys/auto-utils';
|
|
3
2
|
import type { Events } from '../types/events';
|
|
4
3
|
import type { TransactionSignedAndSend } from '../types/transaction';
|
|
5
4
|
export declare const signAndSendTx: (sender: AddressOrPair, tx: SubmittableExtrinsic<'promise', ISubmittableResult>, eventsExpected?: Events, log?: boolean) => Promise<TransactionSignedAndSend>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signAndSendTx.d.ts","sourceRoot":"","sources":["../../src/utils/signAndSendTx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"signAndSendTx.d.ts","sourceRoot":"","sources":["../../src/utils/signAndSendTx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAmB,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAKrF,eAAO,MAAM,aAAa,WAChB,aAAa,MACjB,qBAAqB,SAAS,EAAE,kBAAkB,CAAC,mBACvC,MAAM,QACjB,OAAO,KACX,QAAQ,wBAAwB,CAgClC,CAAA"}
|
package/dist/utils/sudo.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { ApiPromise } from '@
|
|
2
|
-
import type { AddressOrPair, SubmittableExtrinsic } from '@polkadot/api/types';
|
|
3
|
-
import type { ISubmittableResult } from '@polkadot/types/types';
|
|
1
|
+
import type { AddressOrPair, ApiPromise, ISubmittableResult, SubmittableExtrinsic } from '@autonomys/auto-utils';
|
|
4
2
|
import type { Events } from '../types/events';
|
|
5
3
|
export declare const sudo: (api: ApiPromise, sender: AddressOrPair, tx: SubmittableExtrinsic<'promise', ISubmittableResult>, eventsExpected?: Events, log?: boolean) => Promise<import("..").TransactionSignedAndSend>;
|
|
6
4
|
//# sourceMappingURL=sudo.d.ts.map
|
package/dist/utils/sudo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sudo.d.ts","sourceRoot":"","sources":["../../src/utils/sudo.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"sudo.d.ts","sourceRoot":"","sources":["../../src/utils/sudo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI7C,eAAO,MAAM,IAAI,QACV,UAAU,UACP,aAAa,MACjB,qBAAqB,SAAS,EAAE,kBAAkB,CAAC,mBACvC,MAAM,QACjB,OAAO,mDAC6D,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventRecord } from '@
|
|
1
|
+
import type { EventRecord } from '@autonomys/auto-utils';
|
|
2
2
|
import type { Events } from '../types/events';
|
|
3
3
|
import type { EventsValidated } from '../types/transaction';
|
|
4
4
|
export declare const validateEvents: (events: EventRecord[], eventsExpected: Events | undefined, tx: string, block: string, log?: boolean) => EventsValidated;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateEvents.d.ts","sourceRoot":"","sources":["../../src/utils/validateEvents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"validateEvents.d.ts","sourceRoot":"","sources":["../../src/utils/validateEvents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3D,eAAO,MAAM,cAAc,WACjB,WAAW,EAAE,0CAEjB,MAAM,SACH,MAAM,QACR,OAAO,KACX,eAmBF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-consensus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://www.autonomys.net"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@autonomys/auto-utils": "^0.1.
|
|
24
|
+
"@autonomys/auto-utils": "^0.1.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@polkadot/types-codec": "^11.2.1",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"ts-jest": "^29.1.4",
|
|
33
33
|
"typescript": "^5.4.5"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8f1d6171a537e44d29aa19ff2f5c5176046ca0f9"
|
|
36
36
|
}
|
package/dist/address.d.ts
DELETED
package/dist/address.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,YAAa,MAAM,GAAG,UAAU,KAAG,MAAsC,CAAA"}
|
package/dist/address.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// file: src/address.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.address = void 0;
|
|
5
|
-
const keyring_1 = require("@polkadot/keyring");
|
|
6
|
-
const address = (address) => (0, keyring_1.encodeAddress)(address, 2254);
|
|
7
|
-
exports.address = address;
|