@autonomys/auto-utils 1.2.3 → 1.2.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.
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import type { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import { createType } from '@polkadot/types';
|
|
3
|
+
import { Codec } from '../types/query';
|
|
2
4
|
export declare const createAccountIdType: (api: ApiPromise, address: string) => Uint8Array<ArrayBufferLike>;
|
|
5
|
+
export declare const createDomainsChainIdType: (api: ApiPromise, domainId?: string | number) => Codec;
|
|
6
|
+
export declare const createAccountId20Type: (api: ApiPromise, address: string) => Codec;
|
|
7
|
+
export declare const createAccountId32Type: (api: ApiPromise, address: string) => Codec;
|
|
8
|
+
export declare const createMultiAccountIdType: (api: ApiPromise, account: {
|
|
9
|
+
accountId20?: Codec;
|
|
10
|
+
accountId32?: Codec;
|
|
11
|
+
}) => Codec;
|
|
12
|
+
export declare const createTransporterLocationType: (api: ApiPromise, chainId: Codec, accountId: Codec) => Codec;
|
|
13
|
+
export declare const createTransporterToConsensusType: (api: ApiPromise, accountId32: string) => Codec;
|
|
14
|
+
export declare const createTransporterToDomainAccount20Type: (api: ApiPromise, destinationDomainId: string | number, accountId20: string) => Codec;
|
|
15
|
+
export declare const createTransporterToDomainAccount32Type: (api: ApiPromise, destinationDomainId: string | number, accountId32: string) => Codec;
|
|
16
|
+
export declare const createWithdrawStakeAll: (api: ApiPromise) => Codec;
|
|
17
|
+
export declare const createWithdrawStakeByPercent: (api: ApiPromise, percent: string) => Codec;
|
|
18
|
+
export declare const createWithdrawStakeByStake: (api: ApiPromise, stake: string) => Codec;
|
|
19
|
+
export declare const createWithdrawStakeByShares: (api: ApiPromise, shares: string) => Codec;
|
|
20
|
+
export { createType };
|
|
3
21
|
//# sourceMappingURL=createType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createType.d.ts","sourceRoot":"","sources":["../../src/utils/createType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,QAAS,UAAU,UAAU,MAAM,UACQ,CAAA;AAEnF,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/utils/createType.js
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAccountIdType = void 0;
|
|
3
|
+
exports.createType = exports.createWithdrawStakeByShares = exports.createWithdrawStakeByStake = exports.createWithdrawStakeByPercent = exports.createWithdrawStakeAll = exports.createTransporterToDomainAccount32Type = exports.createTransporterToDomainAccount20Type = exports.createTransporterToConsensusType = exports.createTransporterLocationType = exports.createMultiAccountIdType = exports.createAccountId32Type = exports.createAccountId20Type = exports.createDomainsChainIdType = exports.createAccountIdType = void 0;
|
|
4
4
|
const types_1 = require("@polkadot/types");
|
|
5
|
+
Object.defineProperty(exports, "createType", { enumerable: true, get: function () { return types_1.createType; } });
|
|
5
6
|
const createAccountIdType = (api, address) => (0, types_1.createType)(api.registry, 'AccountId', address).toU8a();
|
|
6
7
|
exports.createAccountIdType = createAccountIdType;
|
|
8
|
+
const createDomainsChainIdType = (api, domainId) => (0, types_1.createType)(api.registry, 'SpDomainsChainId', domainId ? { Domain: domainId } : { Consensus: null });
|
|
9
|
+
exports.createDomainsChainIdType = createDomainsChainIdType;
|
|
10
|
+
const createAccountId20Type = (api, address) => (0, types_1.createType)(api.registry, 'AccountId20', address);
|
|
11
|
+
exports.createAccountId20Type = createAccountId20Type;
|
|
12
|
+
const createAccountId32Type = (api, address) => (0, types_1.createType)(api.registry, 'AccountId32', address);
|
|
13
|
+
exports.createAccountId32Type = createAccountId32Type;
|
|
14
|
+
const createMultiAccountIdType = (api, account) => {
|
|
15
|
+
if (!account.accountId20 && !account.accountId32)
|
|
16
|
+
throw new Error('Both accountId20 and accountId32 is undefined');
|
|
17
|
+
if (account.accountId20 && account.accountId32)
|
|
18
|
+
throw new Error('Both accountId20 and accountId32 are defined, define only one');
|
|
19
|
+
return (0, types_1.createType)(api.registry, 'DomainRuntimePrimitivesMultiAccountId', account.accountId20
|
|
20
|
+
? {
|
|
21
|
+
AccountId20: account.accountId20,
|
|
22
|
+
}
|
|
23
|
+
: { AccountId32: account.accountId32 });
|
|
24
|
+
};
|
|
25
|
+
exports.createMultiAccountIdType = createMultiAccountIdType;
|
|
26
|
+
const createTransporterLocationType = (api, chainId, accountId) => (0, types_1.createType)(api.registry, 'PalletTransporterLocation', {
|
|
27
|
+
chainId,
|
|
28
|
+
accountId,
|
|
29
|
+
});
|
|
30
|
+
exports.createTransporterLocationType = createTransporterLocationType;
|
|
31
|
+
const createTransporterToConsensusType = (api, accountId32) => {
|
|
32
|
+
const chainId = (0, exports.createDomainsChainIdType)(api);
|
|
33
|
+
const accountId = (0, exports.createMultiAccountIdType)(api, {
|
|
34
|
+
accountId32: (0, exports.createAccountId32Type)(api, accountId32),
|
|
35
|
+
});
|
|
36
|
+
return (0, exports.createTransporterLocationType)(api, chainId, accountId);
|
|
37
|
+
};
|
|
38
|
+
exports.createTransporterToConsensusType = createTransporterToConsensusType;
|
|
39
|
+
const createTransporterToDomainAccount20Type = (api, destinationDomainId, accountId20) => {
|
|
40
|
+
const chainId = (0, exports.createDomainsChainIdType)(api, destinationDomainId);
|
|
41
|
+
const accountId = (0, exports.createMultiAccountIdType)(api, {
|
|
42
|
+
accountId20: (0, exports.createAccountId20Type)(api, accountId20),
|
|
43
|
+
});
|
|
44
|
+
return (0, exports.createTransporterLocationType)(api, chainId, accountId);
|
|
45
|
+
};
|
|
46
|
+
exports.createTransporterToDomainAccount20Type = createTransporterToDomainAccount20Type;
|
|
47
|
+
const createTransporterToDomainAccount32Type = (api, destinationDomainId, accountId32) => {
|
|
48
|
+
const chainId = (0, exports.createDomainsChainIdType)(api, destinationDomainId);
|
|
49
|
+
const accountId = (0, exports.createMultiAccountIdType)(api, {
|
|
50
|
+
accountId32: (0, exports.createAccountId32Type)(api, accountId32),
|
|
51
|
+
});
|
|
52
|
+
return (0, exports.createTransporterLocationType)(api, chainId, accountId);
|
|
53
|
+
};
|
|
54
|
+
exports.createTransporterToDomainAccount32Type = createTransporterToDomainAccount32Type;
|
|
55
|
+
const createWithdrawStakeAll = (api) => (0, types_1.createType)(api.registry, 'PalletDomainsStakingWithdrawStake', { All: null });
|
|
56
|
+
exports.createWithdrawStakeAll = createWithdrawStakeAll;
|
|
57
|
+
const createWithdrawStakeByPercent = (api, percent) => (0, types_1.createType)(api.registry, 'PalletDomainsStakingWithdrawStake', {
|
|
58
|
+
Percent: percent,
|
|
59
|
+
});
|
|
60
|
+
exports.createWithdrawStakeByPercent = createWithdrawStakeByPercent;
|
|
61
|
+
const createWithdrawStakeByStake = (api, stake) => (0, types_1.createType)(api.registry, 'PalletDomainsStakingWithdrawStake', { Stake: stake });
|
|
62
|
+
exports.createWithdrawStakeByStake = createWithdrawStakeByStake;
|
|
63
|
+
const createWithdrawStakeByShares = (api, shares) => (0, types_1.createType)(api.registry, 'PalletDomainsStakingWithdrawStake', { Shares: shares });
|
|
64
|
+
exports.createWithdrawStakeByShares = createWithdrawStakeByShares;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"browser": {
|
|
42
42
|
"fs": false
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "cc6b1dd67f41f4c2bb20bad78d2a0397f228299b"
|
|
45
45
|
}
|