@bitgo-beta/abstract-substrate 1.0.1-beta.59 → 1.0.1-beta.591
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/dist/src/abstractSubstrateCoin.d.ts +57 -23
- package/dist/src/abstractSubstrateCoin.d.ts.map +1 -1
- package/dist/src/abstractSubstrateCoin.js +335 -62
- package/dist/src/lib/constants.d.ts +2 -0
- package/dist/src/lib/constants.d.ts.map +1 -0
- package/dist/src/lib/constants.js +5 -0
- package/dist/src/lib/errors.d.ts +8 -0
- package/dist/src/lib/errors.d.ts.map +1 -0
- package/dist/src/lib/errors.js +19 -0
- package/dist/src/lib/iface.d.ts +115 -202
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +35 -80
- package/dist/src/lib/index.d.ts +9 -2
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +22 -4
- package/dist/src/lib/keyPair.d.ts +6 -13
- package/dist/src/lib/keyPair.d.ts.map +1 -1
- package/dist/src/lib/keyPair.js +12 -19
- package/dist/src/lib/nativeTransferBuilder.d.ts +61 -0
- package/dist/src/lib/nativeTransferBuilder.d.ts.map +1 -0
- package/dist/src/lib/nativeTransferBuilder.js +150 -0
- package/dist/src/lib/singletonRegistry.d.ts +8 -0
- package/dist/src/lib/singletonRegistry.d.ts.map +1 -0
- package/dist/src/lib/singletonRegistry.js +20 -0
- package/dist/src/lib/transaction.d.ts +74 -0
- package/dist/src/lib/transaction.d.ts.map +1 -0
- package/dist/src/lib/transaction.js +553 -0
- package/dist/src/lib/transactionBuilder.d.ts +121 -0
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -0
- package/dist/src/lib/transactionBuilder.js +334 -0
- package/dist/src/lib/transferBuilder.d.ts +6 -0
- package/dist/src/lib/transferBuilder.d.ts.map +1 -0
- package/dist/src/lib/transferBuilder.js +11 -0
- package/dist/src/lib/txnSchema.d.ts +12 -0
- package/dist/src/lib/txnSchema.d.ts.map +1 -0
- package/dist/src/lib/txnSchema.js +71 -0
- package/dist/src/lib/utils.d.ts +21 -140
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +52 -238
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -5
- package/.eslintignore +0 -5
- package/.mocharc.yml +0 -8
- package/CHANGELOG.md +0 -32
- package/dist/src/lib/iface_utils.d.ts +0 -59
- package/dist/src/lib/iface_utils.d.ts.map +0 -1
- package/dist/src/lib/iface_utils.js +0 -92
- package/dist/src/resources/index.d.ts +0 -3
- package/dist/src/resources/index.d.ts.map +0 -1
- package/dist/src/resources/index.js +0 -19
- package/dist/src/resources/mainnet.d.ts +0 -2
- package/dist/src/resources/mainnet.d.ts.map +0 -1
- package/dist/src/resources/mainnet.js +0 -5
- package/dist/src/resources/westend.d.ts +0 -2
- package/dist/src/resources/westend.d.ts.map +0 -1
- package/dist/src/resources/westend.js +0 -5
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseUtils, Seed } from '@bitgo-beta/sdk-core';
|
|
2
|
+
import { NetworkType } from '@bitgo-beta/statics';
|
|
2
3
|
import { KeyringPair } from '@polkadot/keyring/types';
|
|
3
|
-
import {
|
|
4
|
+
import { UnsignedTransaction } from '@substrate/txwrapper-core';
|
|
4
5
|
import { DecodedSignedTx, DecodedSigningPayload, TypeRegistry } from '@substrate/txwrapper-core/lib/types';
|
|
5
|
-
import { AddProxyBatchCallArgs, BatchArgs, BatchCallObject, HexString, ProxyArgs, StakeArgs, StakeBatchCallArgs, StakeMoreArgs, StakeMoreCallArgs, TransferAllArgs, TransferArgs, TxMethod, UnstakeBatchCallArgs } from './iface';
|
|
6
6
|
import { KeyPair } from '.';
|
|
7
|
+
import { HexString, Material, TransferAllArgs, TransferArgs, TxMethod, AddStakeArgs, RemoveStakeArgs, BondArgs, BondExtraArgs, NominateArgs, ChillArgs, UnbondArgs, WithdrawUnbondedArgs, BatchArgs, MoveStakeArgs } from './iface';
|
|
7
8
|
export declare class Utils implements BaseUtils {
|
|
8
9
|
/** @inheritdoc */
|
|
9
10
|
isValidAddress(address: string): boolean;
|
|
@@ -33,24 +34,6 @@ export declare class Utils implements BaseUtils {
|
|
|
33
34
|
* @returns {Seed} - the object Seed
|
|
34
35
|
*/
|
|
35
36
|
decodeSeed(seed: string): Seed;
|
|
36
|
-
/**
|
|
37
|
-
* Helper function to capitalize the first letter of a string
|
|
38
|
-
*
|
|
39
|
-
* @param {string} val
|
|
40
|
-
* @returns {string}
|
|
41
|
-
*/
|
|
42
|
-
capitalizeFirstLetter(val: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Helper function to decode the internal method hex in case of a proxy transaction
|
|
45
|
-
*
|
|
46
|
-
* @param {string | UnsignedTransaction} tx
|
|
47
|
-
* @param { metadataRpc: string; registry: TypeRegistry } options
|
|
48
|
-
* @returns {TransferArgs}
|
|
49
|
-
*/
|
|
50
|
-
decodeCallMethod(tx: string | UnsignedTransaction, options: {
|
|
51
|
-
metadataRpc: string;
|
|
52
|
-
registry: TypeRegistry;
|
|
53
|
-
}): TransferArgs;
|
|
54
37
|
/**
|
|
55
38
|
* keyPairFromSeed generates an object with secretKey and publicKey using the substrate sdk
|
|
56
39
|
* @param seed 32 bytes long seed
|
|
@@ -80,7 +63,7 @@ export declare class Utils implements BaseUtils {
|
|
|
80
63
|
* @param registry Transaction registry
|
|
81
64
|
* @returns string Serialized transaction
|
|
82
65
|
*/
|
|
83
|
-
serializeSignedTransaction(transaction:
|
|
66
|
+
serializeSignedTransaction(transaction: UnsignedTransaction, signature: HexString, metadataRpc: `0x${string}`, registry: TypeRegistry): string;
|
|
84
67
|
/**
|
|
85
68
|
* Decodes the substrate address from the given format
|
|
86
69
|
*
|
|
@@ -105,93 +88,18 @@ export declare class Utils implements BaseUtils {
|
|
|
105
88
|
*/
|
|
106
89
|
getTxHash(txHex: string): string;
|
|
107
90
|
isSigningPayload(payload: DecodedSigningPayload | DecodedSignedTx): payload is DecodedSigningPayload;
|
|
108
|
-
isProxyTransfer(arg: TxMethod['args']): arg is ProxyArgs;
|
|
109
91
|
isTransfer(arg: TxMethod['args']): arg is TransferArgs;
|
|
110
92
|
isTransferAll(arg: TxMethod['args']): arg is TransferAllArgs;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
93
|
+
isAddStake(arg: TxMethod['args']): arg is AddStakeArgs;
|
|
94
|
+
isRemoveStake(arg: TxMethod['args']): arg is RemoveStakeArgs;
|
|
95
|
+
isBond(arg: TxMethod['args']): arg is BondArgs;
|
|
96
|
+
isBondExtra(arg: TxMethod['args']): arg is BondExtraArgs;
|
|
97
|
+
isNominate(arg: TxMethod['args']): arg is NominateArgs;
|
|
98
|
+
isChill(arg: TxMethod['args']): arg is ChillArgs;
|
|
99
|
+
isUnbond(arg: TxMethod['args']): arg is UnbondArgs;
|
|
100
|
+
isWithdrawUnbonded(arg: TxMethod['args']): arg is WithdrawUnbondedArgs;
|
|
118
101
|
isBatch(arg: TxMethod['args']): arg is BatchArgs;
|
|
119
|
-
|
|
120
|
-
* Returns true if arg is of type BatchArgs and the calls of the batch are staking calls: a stake
|
|
121
|
-
* call (bond) followed by an add proxy call (addProxy), false otherwise.
|
|
122
|
-
*
|
|
123
|
-
* @param arg The object to test.
|
|
124
|
-
*
|
|
125
|
-
* @return true if arg is of type BatchArgs and the calls of the batch are staking calls: a stake
|
|
126
|
-
* call (bond) followed by an add proxy call (addProxy), false otherwise.
|
|
127
|
-
*/
|
|
128
|
-
isStakingBatch(arg: TxMethod['args']): arg is BatchArgs;
|
|
129
|
-
/**
|
|
130
|
-
* Returns true if arg is of type StakeBatchCallArgs, false otherwise.
|
|
131
|
-
*
|
|
132
|
-
* @param arg The object to test.
|
|
133
|
-
*
|
|
134
|
-
* @return true if arg is of type StakeBatchCallArgs, false otherwise.
|
|
135
|
-
*/
|
|
136
|
-
isStakeBatchCallArgs(arg: BatchCallObject['args']): arg is StakeBatchCallArgs;
|
|
137
|
-
/**
|
|
138
|
-
* Returns true if arg is of type AddProxyBatchCallArgs, false otherwise.
|
|
139
|
-
*
|
|
140
|
-
* @param arg The object to test.
|
|
141
|
-
*
|
|
142
|
-
* @return true if arg is of type AddProxyBatchCallArgs, false otherwise.
|
|
143
|
-
*/
|
|
144
|
-
isAddProxyBatchCallArgs(arg: BatchCallObject['args']): arg is AddProxyBatchCallArgs;
|
|
145
|
-
/**
|
|
146
|
-
* Returns true if arg is of type BatchArgs and the calls of the batch are unstaking calls: a remove
|
|
147
|
-
* proxy call (removeProxy), followed by a chill call, and an unstake call (unbond), false otherwise.
|
|
148
|
-
*
|
|
149
|
-
* @param arg The object to test.
|
|
150
|
-
*
|
|
151
|
-
* @return true if arg is of type BatchArgs and the calls of the batch are unstaking calls: a remove
|
|
152
|
-
* proxy call (removeProxy), followed by a chill call, and an unstake call (unbond), false otherwise.
|
|
153
|
-
*/
|
|
154
|
-
isUnstakingBatch(arg: TxMethod['args']): arg is BatchArgs;
|
|
155
|
-
/**
|
|
156
|
-
* Returns true if arg is of type AddProxyBatchCallArgs, false otherwise.
|
|
157
|
-
*
|
|
158
|
-
* @param arg The object to test.
|
|
159
|
-
*
|
|
160
|
-
* @return true if arg is of type AddProxyBatchCallArgs, false otherwise.
|
|
161
|
-
*/
|
|
162
|
-
isRemoveProxyBatchCallArgs(arg: BatchCallObject['args']): arg is AddProxyBatchCallArgs;
|
|
163
|
-
/**
|
|
164
|
-
* Returns true if arg is of type UnstakeBatchCallArgs, false otherwise.
|
|
165
|
-
*
|
|
166
|
-
* @param arg The object to test.
|
|
167
|
-
*
|
|
168
|
-
* @return true if arg is of type UnstakeBatchCallArgs, false otherwise.
|
|
169
|
-
*/
|
|
170
|
-
isUnstakeBatchCallArgs(arg: BatchCallObject['args']): arg is UnstakeBatchCallArgs;
|
|
171
|
-
/**
|
|
172
|
-
* Returns true if arg is of type StakeArgs, false otherwise.
|
|
173
|
-
*
|
|
174
|
-
* @param arg The object to test.
|
|
175
|
-
*
|
|
176
|
-
* @return true if arg is of type StakeArgs, false otherwise.
|
|
177
|
-
*/
|
|
178
|
-
isBond(arg: TxMethod['args']): arg is StakeArgs;
|
|
179
|
-
/**
|
|
180
|
-
* Returns true if arg is of type StakeMoreArgs, false otherwise.
|
|
181
|
-
*
|
|
182
|
-
* @param arg The object to test.
|
|
183
|
-
*
|
|
184
|
-
* @return true if arg is of type StakeMoreArgs, false otherwise.
|
|
185
|
-
*/
|
|
186
|
-
isBondExtra(arg: TxMethod['args'] | BatchCallObject['args']): arg is StakeMoreArgs;
|
|
187
|
-
/**
|
|
188
|
-
* Returns true if arg is of type StakeMoreArgs, false otherwise.
|
|
189
|
-
*
|
|
190
|
-
* @param arg The object to test.
|
|
191
|
-
*
|
|
192
|
-
* @return true if arg is of type StakeMoreArgs, false otherwise.
|
|
193
|
-
*/
|
|
194
|
-
isBondBatchExtra(arg: BatchCallObject['args']): arg is StakeMoreCallArgs;
|
|
102
|
+
isMoveStake(arg: TxMethod['args']): arg is MoveStakeArgs;
|
|
195
103
|
/**
|
|
196
104
|
* extracts and returns the signature in hex format given a raw signed transaction
|
|
197
105
|
*
|
|
@@ -215,43 +123,16 @@ export declare class Utils implements BaseUtils {
|
|
|
215
123
|
* @param hexValue
|
|
216
124
|
*/
|
|
217
125
|
isZeroHex(hexValue: string): boolean;
|
|
126
|
+
getMaterial(networkType: NetworkType): Material;
|
|
218
127
|
/**
|
|
219
|
-
*
|
|
220
|
-
* since substrate addresses differ depending on the network
|
|
221
|
-
* @param networkCoinName
|
|
222
|
-
*/
|
|
223
|
-
getAddressFormat(networkCoinName: DotAssetTypes): DotAddressFormat;
|
|
224
|
-
/**
|
|
225
|
-
* Creates a pure proxy extrinsic. Substrate has renamed anonymous proxies to pure proxies, but
|
|
226
|
-
* the libraries we are using to build transactions have not been updated, as a stop gap we are
|
|
227
|
-
* defining the pure proxy extrinsic here.
|
|
228
|
-
*
|
|
229
|
-
* @param args Arguments to the createPure extrinsic.
|
|
230
|
-
* @param info Common information to all transactions.
|
|
231
|
-
* @param options Chain registry and metadata.
|
|
232
|
-
*/
|
|
233
|
-
pureProxy(args: PureProxyArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction;
|
|
234
|
-
/**
|
|
235
|
-
* Removes '0x' from a given `string` if present.
|
|
236
|
-
*
|
|
237
|
-
* @param {string} str the string value.
|
|
128
|
+
* Decodes a substrate transaction from raw transaction hex
|
|
238
129
|
*
|
|
239
|
-
* @
|
|
130
|
+
* @param {string} txHex - The raw transaction hex string to decode (signed or unsigned)
|
|
131
|
+
* @param {Material} material - Network material containing metadata and chain information
|
|
132
|
+
* @param {boolean} [isImmortalEra] - Whether the transaction uses immortal era (optional)
|
|
133
|
+
* @returns {DecodedSignedTx | DecodedSigningPayload} The decoded transaction object
|
|
240
134
|
*/
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Returns true if a string starts with '0x', false otherwise.
|
|
244
|
-
*
|
|
245
|
-
* @param {string} str the string value.
|
|
246
|
-
*
|
|
247
|
-
* @return {boolean} true if a string starts with '0x', false otherwise.
|
|
248
|
-
*/
|
|
249
|
-
isHexPrefixed(str: string): boolean;
|
|
250
|
-
}
|
|
251
|
-
interface PureProxyArgs extends Args {
|
|
252
|
-
proxyType: string;
|
|
253
|
-
delay: number;
|
|
254
|
-
index: number;
|
|
135
|
+
decodeTransaction(txHex: string, material: Material, isImmortalEra?: boolean): DecodedSignedTx | DecodedSigningPayload;
|
|
255
136
|
}
|
|
256
137
|
declare const utils: Utils;
|
|
257
138
|
export default utils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names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