@bitgo-beta/sdk-coin-flr 1.0.1-beta.83 → 1.0.1-beta.830

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 +145 -3
  2. package/dist/src/flr.d.ts.map +1 -1
  3. package/dist/src/flr.js +463 -3
  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 +2 -0
  14. package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
  15. package/dist/src/lib/transactionBuilder.js +5 -1
  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 +1040 -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 -44
package/dist/src/flr.d.ts CHANGED
@@ -6,18 +6,160 @@
6
6
  * @coinFullName Flare
7
7
  * @coinWebsite https://flare-explorer.flare.network
8
8
  */
9
- import { BaseCoin, BitGoBase, MPCAlgorithm } from '@bitgo-beta/sdk-core';
9
+ import { BaseCoin, BitGoBase, FeeEstimateOptions, IWallet, MPCAlgorithm, MultisigType, Recipient, 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
+ /** @inheritDoc */
26
+ supportsMessageSigning(): boolean;
27
+ /** @inheritDoc */
28
+ supportsSigningTypedData(): boolean;
29
+ protected buildUnsignedSweepTxnTSS(params: RecoverOptions): Promise<OfflineVaultTxInfo | UnsignedSweepTxMPCv2>;
30
+ /**
31
+ * Validates if an address is valid for FLR
32
+ * Also validates P-chain addresses for cross-chain transactions
33
+ * @param {string} address - address to validate
34
+ * @returns {boolean} - validation result
35
+ */
36
+ isValidAddress(address: string): boolean;
37
+ /**
38
+ * Get the corresponding P-chain coin name
39
+ * @returns {string} flrp or tflrp depending on mainnet/testnet
40
+ */
41
+ getFlrP(): string;
42
+ /**
43
+ * Get the atomic transaction builder factory for cross-chain operations
44
+ * @returns {FlrPLib.TransactionBuilderFactory} the atomic builder factory
45
+ */
46
+ protected getAtomicBuilder(): FlrPLib.TransactionBuilderFactory;
47
+ /**
48
+ * Check if this coin is a token
49
+ * @returns {boolean} false for FLR (base chain)
50
+ */
51
+ isToken(): boolean;
52
+ /**
53
+ * Explains an atomic transaction using atomic builder.
54
+ * @param {string} txHex - the transaction hex
55
+ * @returns {Promise<AtomicTransactionExplanation>} the transaction explanation
56
+ * @private
57
+ */
58
+ private explainAtomicTransaction;
59
+ /**
60
+ * Verify signature for an atomic transaction using atomic builder.
61
+ * @param {string} txHex - the transaction hex
62
+ * @returns {Promise<boolean>} true if signature is from the input address
63
+ * @private
64
+ */
65
+ private verifySignatureForAtomicTransaction;
66
+ /**
67
+ * Explain a transaction from txHex, overriding BaseCoins
68
+ * transaction can be either atomic or eth txn.
69
+ * @param {ExplainTransactionOptions} params The options with which to explain the transaction
70
+ * @returns {Promise<TransactionExplanation>} the transaction explanation
71
+ */
72
+ explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
73
+ /**
74
+ * Explains an EVM transaction using regular eth txn builder
75
+ * @param {BaseTransaction} tx - the transaction to explain
76
+ * @returns {Object} the transaction explanation
77
+ * @private
78
+ */
79
+ private explainEVMTransaction;
80
+ /**
81
+ * Verify that a transaction prebuild complies with the original intention
82
+ *
83
+ * @param {VerifyFlrTransactionOptions} params
84
+ * @param params.txParams params object passed to send
85
+ * @param params.txPrebuild prebuild object returned by server
86
+ * @param params.wallet Wallet object to obtain keys to verify against
87
+ * @returns {Promise<boolean>}
88
+ */
89
+ verifyTransaction(params: VerifyFlrTransactionOptions): Promise<boolean>;
90
+ /**
91
+ * Check if an address is a FLR C-chain address (0x format)
92
+ * @param {string} address - the address to check
93
+ * @returns {boolean} true if it's a C-chain address
94
+ * @private
95
+ */
96
+ private static isFLRAddress;
97
+ /**
98
+ * Verify that the coin matches in the prebuild
99
+ * @param {TransactionPrebuild} txPrebuild - the transaction prebuild
100
+ * @returns {boolean} true if coin matches
101
+ */
102
+ verifyCoin(txPrebuild: TransactionPrebuild): boolean;
103
+ /**
104
+ * Coin-specific things done before signing a transaction, i.e. verification
105
+ * @param {PresignTransactionOptions} params - the presign options
106
+ * @returns {Promise<PresignTransactionOptions>}
107
+ */
108
+ presignTransaction(params: PresignTransactionOptions): Promise<PresignTransactionOptions>;
109
+ /**
110
+ * Modify prebuild after receiving it from the server. Add things like nlocktime
111
+ * @param {TransactionPrebuild} params - the transaction prebuild
112
+ * @returns {Promise<TransactionPrebuild>}
113
+ */
114
+ postProcessPrebuild(params: TransactionPrebuild): Promise<TransactionPrebuild>;
115
+ /**
116
+ * Validates that the hop prebuild from the HSM is valid and correct
117
+ * @param {IWallet} wallet The wallet that the prebuild is for
118
+ * @param {HopPrebuild} hopPrebuild The prebuild to validate
119
+ * @param {Object} originalParams The original parameters passed to prebuildTransaction
120
+ * @returns {Promise<void>}
121
+ * @throws Error if The prebuild is invalid
122
+ */
123
+ validateHopPrebuild(wallet: IWallet, hopPrebuild: HopPrebuild, originalParams?: {
124
+ recipients: Recipient[];
125
+ }): Promise<void>;
126
+ /**
127
+ * Modify prebuild before sending it to the server. Add things like hop transaction params
128
+ * @param {BuildOptions} buildParams The whitelisted parameters for this prebuild
129
+ * @param {boolean} buildParams.hop True if this should prebuild a hop tx, else false
130
+ * @param {Recipient[]} buildParams.recipients The recipients array of this transaction
131
+ * @param {Wallet} buildParams.wallet The wallet sending this tx
132
+ * @param {string} buildParams.walletPassphrase the passphrase for this wallet
133
+ * @returns {Promise<BuildOptions>}
134
+ */
135
+ getExtraPrebuildParams(buildParams: BuildOptions): Promise<BuildOptions>;
136
+ /**
137
+ * Creates the extra parameters needed to build a hop transaction
138
+ * @param {HopTransactionBuildOptions} params The original build parameters
139
+ * @returns {Promise<HopParams>} extra parameters object to merge with the original build parameters object and send to the platform
140
+ */
141
+ createHopTransactionParams({ recipients, type }: HopTransactionBuildOptions): Promise<HopParams>;
142
+ /**
143
+ * Fetch fee estimate information from the server
144
+ * @param {FeeEstimateOptions} params The params passed into the function
145
+ * @param {Boolean} [params.hop] True if we should estimate fee for a hop transaction
146
+ * @param {String} [params.recipient] The recipient of the transaction to estimate a send to
147
+ * @param {String} [params.data] The data to estimate a send for
148
+ * @returns {Promise<FeeEstimate>} The fee info returned from the server
149
+ */
150
+ feeEstimate(params: FeeEstimateOptions): Promise<FeeEstimate>;
151
+ /**
152
+ * Calculate tx hash like evm from tx hex.
153
+ * @param {string} tx - the transaction hex
154
+ * @returns {Buffer} tx hash
155
+ */
156
+ static getTxHash(tx: string): Buffer;
157
+ /**
158
+ * Make a query to Flare explorer for information such as balance, token balance, solidity calls
159
+ * @param {Object} query key-value pairs of parameters to append after /api
160
+ * @param {string} apiKey optional API key to use instead of the one from the environment
161
+ * @returns {Promise<Object>} response from Flare explorer
162
+ */
163
+ recoveryBlockchainExplorerQuery(query: Record<string, string>, apiKey?: string): Promise<Record<string, unknown>>;
22
164
  }
23
165
  //# sourceMappingURL=flr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flr.d.ts","sourceRoot":"","sources":["../../src/flr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAU,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAS,MAAM,qBAAqB,CAAC;AACzE,OAAO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