@bitgo-beta/sdk-coin-flr 1.0.1-beta.13 → 1.0.1-beta.1300

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.
Files changed (40) hide show
  1. package/dist/src/flr.d.ts +149 -4
  2. package/dist/src/flr.d.ts.map +1 -1
  3. package/dist/src/flr.js +475 -4
  4. package/dist/src/flrToken.d.ts +26 -0
  5. package/dist/src/flrToken.d.ts.map +1 -0
  6. package/dist/src/flrToken.js +49 -0
  7. package/dist/src/iface.d.ts +148 -0
  8. package/dist/src/iface.d.ts.map +1 -0
  9. package/dist/src/iface.js +3 -0
  10. package/dist/src/index.d.ts +2 -0
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/index.js +3 -1
  13. package/dist/src/lib/transactionBuilder.d.ts +3 -1
  14. package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
  15. package/dist/src/lib/transactionBuilder.js +7 -3
  16. package/dist/src/register.d.ts.map +1 -1
  17. package/dist/src/register.js +5 -1
  18. package/dist/test/resources.d.ts +42 -0
  19. package/dist/test/resources.d.ts.map +1 -0
  20. package/dist/test/resources.js +117 -0
  21. package/dist/test/unit/flr.d.ts +2 -0
  22. package/dist/test/unit/flr.d.ts.map +1 -0
  23. package/dist/test/unit/flr.js +1086 -0
  24. package/dist/test/unit/flrToken.d.ts +2 -0
  25. package/dist/test/unit/flrToken.d.ts.map +1 -0
  26. package/dist/test/unit/flrToken.js +30 -0
  27. package/dist/test/unit/getBuilder.d.ts +3 -0
  28. package/dist/test/unit/getBuilder.d.ts.map +1 -0
  29. package/dist/test/unit/getBuilder.js +10 -0
  30. package/dist/test/unit/transactionBuilder/send.d.ts +2 -0
  31. package/dist/test/unit/transactionBuilder/send.d.ts.map +1 -0
  32. package/dist/test/unit/transactionBuilder/send.js +19 -0
  33. package/dist/test/unit/utils.d.ts +2 -0
  34. package/dist/test/unit/utils.d.ts.map +1 -0
  35. package/dist/test/unit/utils.js +29 -0
  36. package/dist/tsconfig.tsbuildinfo +1 -0
  37. package/package.json +22 -10
  38. package/.eslintignore +0 -5
  39. package/.mocharc.yml +0 -8
  40. package/CHANGELOG.md +0 -22
package/dist/src/flr.d.ts CHANGED
@@ -4,20 +4,165 @@
4
4
  * - Doc: https://docs.flare.network/user/wallets/
5
5
  *
6
6
  * @coinFullName Flare
7
- * @coinWebsite https://flare-explorer.flare.network
7
+ * @coinWebsite https://flarescan.com
8
8
  */
9
- import { BaseCoin, BitGoBase, MPCAlgorithm } from '@bitgo-beta/sdk-core';
9
+ import { BaseCoin, BitGoBase, FeeEstimateOptions, IWallet, MPCAlgorithm, MultisigType, Recipient, SignableTransaction, TransactionExplanation } from '@bitgo-beta/sdk-core';
10
10
  import { BaseCoin as StaticsBaseCoin } from '@bitgo-beta/statics';
11
- import { AbstractEthLikeNewCoins } from '@bitgo-beta/abstract-eth';
11
+ import { AbstractEthLikeNewCoins, UnsignedSweepTxMPCv2, RecoverOptions, OfflineVaultTxInfo } from '@bitgo-beta/abstract-eth';
12
12
  import { TransactionBuilder } from './lib';
13
+ import { FlrPLib } from '@bitgo-beta/sdk-coin-flrp';
14
+ import { BuildOptions, ExplainTransactionOptions, FeeEstimate, HopParams, HopPrebuild, HopTransactionBuildOptions, PresignTransactionOptions, TransactionPrebuild, VerifyFlrTransactionOptions } from './iface';
13
15
  export declare class Flr extends AbstractEthLikeNewCoins {
14
16
  protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>);
15
17
  static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin;
16
18
  protected getTransactionBuilder(): TransactionBuilder;
17
19
  /** @inheritDoc */
18
20
  supportsTss(): boolean;
21
+ /** inherited doc */
22
+ getDefaultMultisigType(): MultisigType;
19
23
  /** @inheritDoc */
20
24
  getMPCAlgorithm(): MPCAlgorithm;
21
- recoveryBlockchainExplorerQuery(query: Record<string, string>): Promise<Record<string, unknown>>;
25
+ /**
26
+ * Returns true when the signableHex for this transaction is already the
27
+ * final signing hash. Cross-chain export atomic transactions from FLR
28
+ * C-chain to FLRP P-chain are pre-hashed with SHA-256(txBody); the MPC
29
+ * signing flow must use that digest directly without applying keccak256.
30
+ */
31
+ isSignablePreHashed(unsignedTx: SignableTransaction): boolean;
32
+ protected buildUnsignedSweepTxnTSS(params: RecoverOptions): Promise<OfflineVaultTxInfo | UnsignedSweepTxMPCv2>;
33
+ /**
34
+ * Validates if an address is valid for FLR
35
+ * Also validates P-chain addresses for cross-chain transactions
36
+ * @param {string} address - address to validate
37
+ * @returns {boolean} - validation result
38
+ */
39
+ isValidAddress(address: string): boolean;
40
+ /**
41
+ * Get the corresponding P-chain coin name
42
+ * @returns {string} flrp or tflrp depending on mainnet/testnet
43
+ */
44
+ getFlrP(): string;
45
+ /**
46
+ * Get the atomic transaction builder factory for cross-chain operations
47
+ * @returns {FlrPLib.TransactionBuilderFactory} the atomic builder factory
48
+ */
49
+ protected getAtomicBuilder(): FlrPLib.TransactionBuilderFactory;
50
+ /**
51
+ * Check if this coin is a token
52
+ * @returns {boolean} false for FLR (base chain)
53
+ */
54
+ isToken(): boolean;
55
+ /**
56
+ * Explains an atomic transaction using atomic builder.
57
+ * @param {string} txHex - the transaction hex
58
+ * @returns {Promise<AtomicTransactionExplanation>} the transaction explanation
59
+ * @private
60
+ */
61
+ private explainAtomicTransaction;
62
+ /**
63
+ * Verify signature for an atomic transaction using atomic builder.
64
+ * @param {string} txHex - the transaction hex
65
+ * @returns {Promise<boolean>} true if signature is from the input address
66
+ * @private
67
+ */
68
+ private verifySignatureForAtomicTransaction;
69
+ /**
70
+ * Explain a transaction from txHex, overriding BaseCoins
71
+ * transaction can be either atomic or eth txn.
72
+ * @param {ExplainTransactionOptions} params The options with which to explain the transaction
73
+ * @returns {Promise<TransactionExplanation>} the transaction explanation
74
+ */
75
+ explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
76
+ /**
77
+ * Explains an EVM transaction using regular eth txn builder
78
+ * @param {BaseTransaction} tx - the transaction to explain
79
+ * @returns {Object} the transaction explanation
80
+ * @private
81
+ */
82
+ private explainEVMTransaction;
83
+ /**
84
+ * Verify that a transaction prebuild complies with the original intention
85
+ *
86
+ * @param {VerifyFlrTransactionOptions} params
87
+ * @param params.txParams params object passed to send
88
+ * @param params.txPrebuild prebuild object returned by server
89
+ * @param params.wallet Wallet object to obtain keys to verify against
90
+ * @returns {Promise<boolean>}
91
+ */
92
+ verifyTransaction(params: VerifyFlrTransactionOptions): Promise<boolean>;
93
+ /**
94
+ * Check if an address is a FLR C-chain address (0x format)
95
+ * @param {string} address - the address to check
96
+ * @returns {boolean} true if it's a C-chain address
97
+ * @private
98
+ */
99
+ private static isFLRAddress;
100
+ /**
101
+ * Verify that the coin matches in the prebuild
102
+ * @param {TransactionPrebuild} txPrebuild - the transaction prebuild
103
+ * @returns {boolean} true if coin matches
104
+ */
105
+ verifyCoin(txPrebuild: TransactionPrebuild): boolean;
106
+ /**
107
+ * Coin-specific things done before signing a transaction, i.e. verification
108
+ * @param {PresignTransactionOptions} params - the presign options
109
+ * @returns {Promise<PresignTransactionOptions>}
110
+ */
111
+ presignTransaction(params: PresignTransactionOptions): Promise<PresignTransactionOptions>;
112
+ /**
113
+ * Modify prebuild after receiving it from the server. Add things like nlocktime
114
+ * @param {TransactionPrebuild} params - the transaction prebuild
115
+ * @returns {Promise<TransactionPrebuild>}
116
+ */
117
+ postProcessPrebuild(params: TransactionPrebuild): Promise<TransactionPrebuild>;
118
+ /**
119
+ * Validates that the hop prebuild from the HSM is valid and correct
120
+ * @param {IWallet} wallet The wallet that the prebuild is for
121
+ * @param {HopPrebuild} hopPrebuild The prebuild to validate
122
+ * @param {Object} originalParams The original parameters passed to prebuildTransaction
123
+ * @returns {Promise<void>}
124
+ * @throws Error if The prebuild is invalid
125
+ */
126
+ validateHopPrebuild(wallet: IWallet, hopPrebuild: HopPrebuild, originalParams?: {
127
+ recipients: Recipient[];
128
+ }): Promise<void>;
129
+ /**
130
+ * Modify prebuild before sending it to the server. Add things like hop transaction params
131
+ * @param {BuildOptions} buildParams The whitelisted parameters for this prebuild
132
+ * @param {boolean} buildParams.hop True if this should prebuild a hop tx, else false
133
+ * @param {Recipient[]} buildParams.recipients The recipients array of this transaction
134
+ * @param {Wallet} buildParams.wallet The wallet sending this tx
135
+ * @param {string} buildParams.walletPassphrase the passphrase for this wallet
136
+ * @returns {Promise<BuildOptions>}
137
+ */
138
+ getExtraPrebuildParams(buildParams: BuildOptions): Promise<BuildOptions>;
139
+ /**
140
+ * Creates the extra parameters needed to build a hop transaction
141
+ * @param {HopTransactionBuildOptions} params The original build parameters
142
+ * @returns {Promise<HopParams>} extra parameters object to merge with the original build parameters object and send to the platform
143
+ */
144
+ createHopTransactionParams({ recipients, type }: HopTransactionBuildOptions): Promise<HopParams>;
145
+ /**
146
+ * Fetch fee estimate information from the server
147
+ * @param {FeeEstimateOptions} params The params passed into the function
148
+ * @param {Boolean} [params.hop] True if we should estimate fee for a hop transaction
149
+ * @param {String} [params.recipient] The recipient of the transaction to estimate a send to
150
+ * @param {String} [params.data] The data to estimate a send for
151
+ * @returns {Promise<FeeEstimate>} The fee info returned from the server
152
+ */
153
+ feeEstimate(params: FeeEstimateOptions): Promise<FeeEstimate>;
154
+ /**
155
+ * Calculate tx hash like evm from tx hex.
156
+ * @param {string} tx - the transaction hex
157
+ * @returns {Buffer} tx hash
158
+ */
159
+ static getTxHash(tx: string): Buffer;
160
+ /**
161
+ * Make a query to Flare explorer for information such as balance, token balance, solidity calls
162
+ * @param {Object} query key-value pairs of parameters to append after /api
163
+ * @param {string} apiKey optional API key to use instead of the one from the environment
164
+ * @returns {Promise<Object>} response from Flare explorer
165
+ */
166
+ recoveryBlockchainExplorerQuery(query: Record<string, string>, apiKey?: string): Promise<Record<string, unknown>>;
22
167
  }
23
168
  //# sourceMappingURL=flr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flr.d.ts","sourceRoot":"","sources":["../../src/fl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