From 94680a69f43473f3e08233e6da6c04974e8d4cbc Mon Sep 17 00:00:00 2001 From: Alex Stone Date: Tue, 17 Dec 2024 08:34:30 -0800 Subject: [PATCH 01/25] chore: Bump OpenAPI client and resolve type changes This resolves type changes to the SmartContract object as well as to the WalletWebhookActivity object --- src/client/api.ts | 1438 ++++++++++++++++++++---------- src/coinbase/smart_contract.ts | 74 +- src/coinbase/types.ts | 10 +- src/tests/smart_contract_test.ts | 63 +- src/tests/utils.ts | 19 +- src/tests/wallet_address_test.ts | 6 +- src/tests/webhook_test.ts | 7 +- 7 files changed, 1101 insertions(+), 516 deletions(-) diff --git a/src/client/api.ts b/src/client/api.ts index 9735beff..39ca17cf 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -5,7 +5,7 @@ * This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. * * The version of the OpenAPI document: 0.0.1-alpha - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -24,7 +24,7 @@ import type { RequestArgs } from './base'; import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; /** - * + * * @export * @interface Address */ @@ -61,13 +61,13 @@ export interface Address { 'index': number; } /** - * + * * @export * @interface AddressBalanceList */ export interface AddressBalanceList { /** - * + * * @type {Array} * @memberof AddressBalanceList */ @@ -92,13 +92,13 @@ export interface AddressBalanceList { 'total_count': number; } /** - * + * * @export * @interface AddressHistoricalBalanceList */ export interface AddressHistoricalBalanceList { /** - * + * * @type {Array} * @memberof AddressHistoricalBalanceList */ @@ -117,13 +117,13 @@ export interface AddressHistoricalBalanceList { 'next_page': string; } /** - * + * * @export * @interface AddressList */ export interface AddressList { /** - * + * * @type {Array
} * @memberof AddressList */ @@ -154,13 +154,13 @@ export interface AddressList { */ export interface AddressReputation { /** - * The reputation score of a wallet address which lie between 0 to 100. + * The score of a wallet address, ranging from -100 to 100. A negative score indicates a bad reputation, while a positive score indicates a good reputation. * @type {number} * @memberof AddressReputation */ - 'reputation_score': number; + 'score': number; /** - * + * * @type {AddressReputationMetadata} * @memberof AddressReputation */ @@ -234,26 +234,13 @@ export interface AddressReputationMetadata { 'smart_contract_deployments': number; } /** - * The risk score of a blockchain address. - * @export - * @interface AddressRisk - */ -export interface AddressRisk { - /** - * The lower the score is, the higher the risk is. The score lies between -100 to 0. - * @type {number} - * @memberof AddressRisk - */ - 'risk_score': number; -} -/** - * + * * @export * @interface AddressTransactionList */ export interface AddressTransactionList { /** - * + * * @type {Array} * @memberof AddressTransactionList */ @@ -315,14 +302,14 @@ export interface Balance { */ 'amount': string; /** - * + * * @type {Asset} * @memberof Balance */ 'asset': Asset; } /** - * + * * @export * @interface BroadcastContractInvocationRequest */ @@ -335,7 +322,7 @@ export interface BroadcastContractInvocationRequest { 'signed_payload': string; } /** - * + * * @export * @interface BroadcastStakingOperationRequest */ @@ -354,7 +341,7 @@ export interface BroadcastStakingOperationRequest { 'transaction_index': number; } /** - * + * * @export * @interface BroadcastTradeRequest */ @@ -373,7 +360,7 @@ export interface BroadcastTradeRequest { 'approve_transaction_signed_payload'?: string; } /** - * + * * @export * @interface BroadcastTransferRequest */ @@ -386,7 +373,7 @@ export interface BroadcastTransferRequest { 'signed_payload': string; } /** - * + * * @export * @interface BuildStakingOperationRequest */ @@ -593,20 +580,20 @@ export interface ContractInvocation { */ 'amount': string; /** - * + * * @type {Transaction} * @memberof ContractInvocation */ 'transaction': Transaction; } /** - * + * * @export * @interface ContractInvocationList */ export interface ContractInvocationList { /** - * + * * @type {Array} * @memberof ContractInvocationList */ @@ -631,7 +618,7 @@ export interface ContractInvocationList { 'total_count': number; } /** - * + * * @export * @interface CreateAddressRequest */ @@ -656,7 +643,7 @@ export interface CreateAddressRequest { 'address_index'?: number; } /** - * + * * @export * @interface CreateContractInvocationRequest */ @@ -693,7 +680,7 @@ export interface CreateContractInvocationRequest { 'amount'?: string; } /** - * + * * @export * @interface CreateFundOperationRequest */ @@ -718,7 +705,7 @@ export interface CreateFundOperationRequest { 'fund_quote_id'?: string; } /** - * + * * @export * @interface CreateFundQuoteRequest */ @@ -737,7 +724,7 @@ export interface CreateFundQuoteRequest { 'asset_id': string; } /** - * + * * @export * @interface CreatePayloadSignatureRequest */ @@ -756,7 +743,7 @@ export interface CreatePayloadSignatureRequest { 'signature'?: string; } /** - * + * * @export * @interface CreateServerSignerRequest */ @@ -781,19 +768,19 @@ export interface CreateServerSignerRequest { 'is_mpc': boolean; } /** - * + * * @export * @interface CreateSmartContractRequest */ export interface CreateSmartContractRequest { /** - * + * * @type {SmartContractType} * @memberof CreateSmartContractRequest */ 'type': SmartContractType; /** - * + * * @type {SmartContractOptions} * @memberof CreateSmartContractRequest */ @@ -802,7 +789,7 @@ export interface CreateSmartContractRequest { /** - * + * * @export * @interface CreateStakingOperationRequest */ @@ -833,7 +820,7 @@ export interface CreateStakingOperationRequest { 'options': { [key: string]: string; }; } /** - * + * * @export * @interface CreateTradeRequest */ @@ -858,7 +845,7 @@ export interface CreateTradeRequest { 'to_asset_id': string; } /** - * + * * @export * @interface CreateTransferRequest */ @@ -895,13 +882,13 @@ export interface CreateTransferRequest { 'gasless'?: boolean; } /** - * + * * @export * @interface CreateWalletRequest */ export interface CreateWalletRequest { /** - * + * * @type {CreateWalletRequestWallet} * @memberof CreateWalletRequest */ @@ -927,7 +914,7 @@ export interface CreateWalletRequestWallet { 'use_server_signer'?: boolean; } /** - * + * * @export * @interface CreateWalletWebhookRequest */ @@ -946,7 +933,7 @@ export interface CreateWalletWebhookRequest { 'signature_header'?: string; } /** - * + * * @export * @interface CreateWebhookRequest */ @@ -958,13 +945,13 @@ export interface CreateWebhookRequest { */ 'network_id': string; /** - * + * * @type {WebhookEventType} * @memberof CreateWebhookRequest */ 'event_type': WebhookEventType; /** - * + * * @type {WebhookEventTypeFilter} * @memberof CreateWebhookRequest */ @@ -1003,14 +990,14 @@ export interface CryptoAmount { */ 'amount': string; /** - * + * * @type {Asset} * @memberof CryptoAmount */ 'asset': Asset; } /** - * + * * @export * @interface DeploySmartContractRequest */ @@ -1193,25 +1180,25 @@ export interface ERC721TransferEvent { 'tokenId'?: string; } /** - * + * * @export * @interface EthereumTokenTransfer */ export interface EthereumTokenTransfer { /** - * + * * @type {string} * @memberof EthereumTokenTransfer */ 'contract_address': string; /** - * + * * @type {string} * @memberof EthereumTokenTransfer */ 'from_address': string; /** - * + * * @type {string} * @memberof EthereumTokenTransfer */ @@ -1229,13 +1216,13 @@ export interface EthereumTokenTransfer { */ 'token_id'?: string; /** - * + * * @type {number} * @memberof EthereumTokenTransfer */ 'log_index': number; /** - * + * * @type {TokenTransferType} * @memberof EthereumTokenTransfer */ @@ -1244,7 +1231,7 @@ export interface EthereumTokenTransfer { /** - * + * * @export * @interface EthereumTransaction */ @@ -1328,19 +1315,19 @@ export interface EthereumTransaction { */ 'priority_fee_per_gas'?: number; /** - * + * * @type {EthereumTransactionAccessList} * @memberof EthereumTransaction */ 'transaction_access_list'?: EthereumTransactionAccessList; /** - * + * * @type {Array} * @memberof EthereumTransaction */ 'token_transfers'?: Array; /** - * + * * @type {Array} * @memberof EthereumTransaction */ @@ -1357,155 +1344,161 @@ export interface EthereumTransaction { * @memberof EthereumTransaction */ 'mint'?: string; + /** + * RLP encoded transaction as a hex string (prefixed with 0x) for native compatibility with popular eth clients such as etherjs, viem etc. + * @type {string} + * @memberof EthereumTransaction + */ + 'rlp_encoded_tx'?: string; } /** - * + * * @export * @interface EthereumTransactionAccess */ export interface EthereumTransactionAccess { /** - * + * * @type {string} * @memberof EthereumTransactionAccess */ 'address'?: string; /** - * + * * @type {Array} * @memberof EthereumTransactionAccess */ 'storage_keys'?: Array; } /** - * + * * @export * @interface EthereumTransactionAccessList */ export interface EthereumTransactionAccessList { /** - * + * * @type {Array} * @memberof EthereumTransactionAccessList */ 'access_list'?: Array; } /** - * + * * @export * @interface EthereumTransactionFlattenedTrace */ export interface EthereumTransactionFlattenedTrace { /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'error'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'type'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'from'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'to'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'value'?: string; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ 'gas'?: number; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ 'gas_used'?: number; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'input'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'output'?: string; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ 'sub_traces'?: number; /** - * + * * @type {Array} * @memberof EthereumTransactionFlattenedTrace */ 'trace_address'?: Array; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'trace_type'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'call_type'?: string; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'trace_id'?: string; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ 'status'?: number; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'block_hash'?: string; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ 'block_number'?: number; /** - * + * * @type {string} * @memberof EthereumTransactionFlattenedTrace */ 'transaction_hash'?: string; /** - * + * * @type {number} * @memberof EthereumTransactionFlattenedTrace */ @@ -1560,13 +1553,13 @@ export interface EthereumValidatorMetadata { */ 'withdrawableEpoch': string; /** - * + * * @type {Balance} * @memberof EthereumValidatorMetadata */ 'balance': Balance; /** - * + * * @type {Balance} * @memberof EthereumValidatorMetadata */ @@ -1591,14 +1584,14 @@ export interface FaucetTransaction { */ 'transaction_link': string; /** - * + * * @type {Transaction} * @memberof FaucetTransaction */ 'transaction': Transaction; } /** - * + * * @export * @interface FeatureSet */ @@ -1641,13 +1634,13 @@ export interface FeatureSet { 'gasless_send': boolean; } /** - * + * * @export * @interface FetchHistoricalStakingBalances200Response */ export interface FetchHistoricalStakingBalances200Response { /** - * + * * @type {Array} * @memberof FetchHistoricalStakingBalances200Response */ @@ -1666,13 +1659,13 @@ export interface FetchHistoricalStakingBalances200Response { 'next_page': string; } /** - * + * * @export * @interface FetchStakingRewards200Response */ export interface FetchStakingRewards200Response { /** - * + * * @type {Array} * @memberof FetchStakingRewards200Response */ @@ -1691,7 +1684,7 @@ export interface FetchStakingRewards200Response { 'next_page': string; } /** - * + * * @export * @interface FetchStakingRewardsRequest */ @@ -1727,7 +1720,7 @@ export interface FetchStakingRewardsRequest { */ 'end_time': string; /** - * + * * @type {StakingRewardFormat} * @memberof FetchStakingRewardsRequest */ @@ -1785,19 +1778,19 @@ export interface FundOperation { */ 'address_id': string; /** - * + * * @type {CryptoAmount} * @memberof FundOperation */ 'crypto_amount': CryptoAmount; /** - * + * * @type {FiatAmount} * @memberof FundOperation */ 'fiat_amount': FiatAmount; /** - * + * * @type {FundOperationFees} * @memberof FundOperation */ @@ -1825,13 +1818,13 @@ export type FundOperationStatusEnum = typeof FundOperationStatusEnum[keyof typeo */ export interface FundOperationFees { /** - * + * * @type {FiatAmount} * @memberof FundOperationFees */ 'buy_fee': FiatAmount; /** - * + * * @type {CryptoAmount} * @memberof FundOperationFees */ @@ -1844,7 +1837,7 @@ export interface FundOperationFees { */ export interface FundOperationList { /** - * + * * @type {Array} * @memberof FundOperationList */ @@ -1899,13 +1892,13 @@ export interface FundQuote { */ 'address_id': string; /** - * + * * @type {CryptoAmount} * @memberof FundQuote */ 'crypto_amount': CryptoAmount; /** - * + * * @type {FiatAmount} * @memberof FundQuote */ @@ -1917,14 +1910,14 @@ export interface FundQuote { */ 'expires_at': string; /** - * + * * @type {FundOperationFees} * @memberof FundQuote */ 'fees': FundOperationFees; } /** - * + * * @export * @interface GetStakingContextRequest */ @@ -1979,7 +1972,7 @@ export interface HistoricalBalance { */ 'block_height': string; /** - * + * * @type {Asset} * @memberof HistoricalBalance */ @@ -2049,13 +2042,13 @@ export interface NFTContractOptions { 'base_uri': string; } /** - * + * * @export * @interface Network */ export interface Network { /** - * + * * @type {NetworkIdentifier} * @memberof Network */ @@ -2085,13 +2078,13 @@ export interface Network { */ 'is_testnet': boolean; /** - * + * * @type {Asset} * @memberof Network */ 'native_asset': Asset; /** - * + * * @type {FeatureSet} * @memberof Network */ @@ -2282,13 +2275,13 @@ export const PayloadSignatureStatusEnum = { export type PayloadSignatureStatusEnum = typeof PayloadSignatureStatusEnum[keyof typeof PayloadSignatureStatusEnum]; /** - * + * * @export * @interface PayloadSignatureList */ export interface PayloadSignatureList { /** - * + * * @type {Array} * @memberof PayloadSignatureList */ @@ -2313,7 +2306,7 @@ export interface PayloadSignatureList { 'total_count': number; } /** - * + * * @export * @interface ReadContractRequest */ @@ -2337,6 +2330,25 @@ export interface ReadContractRequest { */ 'abi'?: string; } +/** + * Smart Contract data to be registered + * @export + * @interface RegisterSmartContractRequest + */ +export interface RegisterSmartContractRequest { + /** + * ABI of the smart contract + * @type {string} + * @memberof RegisterSmartContractRequest + */ + 'abi': string; + /** + * Name of the smart contract + * @type {string} + * @memberof RegisterSmartContractRequest + */ + 'contract_name'?: string; +} /** * An event representing a seed creation. * @export @@ -2425,7 +2437,7 @@ export interface ServerSignerEvent { */ 'server_signer_id': string; /** - * + * * @type {ServerSignerEventEvent} * @memberof ServerSignerEvent */ @@ -2438,13 +2450,13 @@ export interface ServerSignerEvent { export type ServerSignerEventEvent = SeedCreationEvent | SignatureCreationEvent; /** - * + * * @export * @interface ServerSignerEventList */ export interface ServerSignerEventList { /** - * + * * @type {Array} * @memberof ServerSignerEventList */ @@ -2469,13 +2481,13 @@ export interface ServerSignerEventList { 'total_count': number; } /** - * + * * @export * @interface ServerSignerList */ export interface ServerSignerList { /** - * + * * @type {Array} * @memberof ServerSignerList */ @@ -2542,7 +2554,7 @@ export interface SignatureCreationEvent { */ 'signing_payload': string; /** - * + * * @type {TransactionType} * @memberof SignatureCreationEvent */ @@ -2581,7 +2593,7 @@ export interface SignatureCreationEventResult { */ 'address_id': string; /** - * + * * @type {TransactionType} * @memberof SignatureCreationEventResult */ @@ -2633,7 +2645,7 @@ export interface SignedVoluntaryExitMessageMetadata { */ export interface SmartContract { /** - * The unique identifier of the smart contract + * The unique identifier of the smart contract. * @type {string} * @memberof SmartContract */ @@ -2645,11 +2657,11 @@ export interface SmartContract { */ 'network_id': string; /** - * The ID of the wallet that deployed the smart contract + * The ID of the wallet that deployed the smart contract. If this smart contract was deployed externally, this will be omitted. * @type {string} * @memberof SmartContract */ - 'wallet_id': string; + 'wallet_id'?: string; /** * The EVM address of the smart contract * @type {string} @@ -2657,23 +2669,29 @@ export interface SmartContract { */ 'contract_address': string; /** - * The EVM address of the account that deployed the smart contract + * The name of the smart contract * @type {string} * @memberof SmartContract */ - 'deployer_address': string; + 'contract_name': string; /** - * + * The EVM address of the account that deployed the smart contract. If this smart contract was deployed externally, this will be omitted. + * @type {string} + * @memberof SmartContract + */ + 'deployer_address'?: string; + /** + * * @type {SmartContractType} * @memberof SmartContract */ 'type': SmartContractType; /** - * + * * @type {SmartContractOptions} * @memberof SmartContract */ - 'options': SmartContractOptions; + 'options'?: SmartContractOptions; /** * The JSON-encoded ABI of the contract * @type {string} @@ -2681,11 +2699,17 @@ export interface SmartContract { */ 'abi': string; /** - * + * * @type {Transaction} * @memberof SmartContract */ - 'transaction': Transaction; + 'transaction'?: Transaction; + /** + * Whether the smart contract was deployed externally. If true, the deployer_address and transaction will be omitted. + * @type {boolean} + * @memberof SmartContract + */ + 'is_external': boolean; } @@ -2805,13 +2829,13 @@ export interface SmartContractActivityEvent { 'value'?: number; } /** - * + * * @export * @interface SmartContractList */ export interface SmartContractList { /** - * + * * @type {Array} * @memberof SmartContractList */ @@ -2845,20 +2869,21 @@ export type SmartContractOptions = MultiTokenContractOptions | NFTContractOption export const SmartContractType = { Erc20: 'erc20', Erc721: 'erc721', - Erc1155: 'erc1155' + Erc1155: 'erc1155', + Custom: 'custom' } as const; export type SmartContractType = typeof SmartContractType[keyof typeof SmartContractType]; /** - * + * * @export * @interface SolidityValue */ export interface SolidityValue { /** - * + * * @type {string} * @memberof SolidityValue */ @@ -3020,13 +3045,13 @@ export interface StakingBalance { */ 'date': string; /** - * + * * @type {Balance} * @memberof StakingBalance */ 'bonded_stake': Balance; /** - * + * * @type {Balance} * @memberof StakingBalance */ @@ -3045,32 +3070,32 @@ export interface StakingBalance { */ export interface StakingContext { /** - * + * * @type {StakingContextContext} * @memberof StakingContext */ 'context': StakingContextContext; } /** - * + * * @export * @interface StakingContextContext */ export interface StakingContextContext { /** - * + * * @type {Balance} * @memberof StakingContextContext */ 'stakeable_balance': Balance; /** - * + * * @type {Balance} * @memberof StakingContextContext */ 'unstakeable_balance': Balance; /** - * + * * @type {Balance} * @memberof StakingContextContext */ @@ -3119,7 +3144,7 @@ export interface StakingOperation { */ 'transactions': Array; /** - * + * * @type {StakingOperationMetadata} * @memberof StakingOperation */ @@ -3172,13 +3197,13 @@ export interface StakingReward { */ 'state': StakingRewardStateEnum; /** - * + * * @type {StakingRewardFormat} * @memberof StakingReward */ 'format': StakingRewardFormat; /** - * + * * @type {StakingRewardUSDValue} * @memberof StakingReward */ @@ -3309,7 +3334,7 @@ export interface Trade { */ 'from_amount': string; /** - * + * * @type {Asset} * @memberof Trade */ @@ -3321,32 +3346,32 @@ export interface Trade { */ 'to_amount': string; /** - * + * * @type {Asset} * @memberof Trade */ 'to_asset': Asset; /** - * + * * @type {Transaction} * @memberof Trade */ 'transaction': Transaction; /** - * + * * @type {Transaction} * @memberof Trade */ 'approve_transaction'?: Transaction; } /** - * + * * @export * @interface TradeList */ export interface TradeList { /** - * + * * @type {Array} * @memberof TradeList */ @@ -3437,7 +3462,7 @@ export interface Transaction { */ 'status': TransactionStatusEnum; /** - * + * * @type {TransactionContent} * @memberof Transaction */ @@ -3462,7 +3487,7 @@ export type TransactionStatusEnum = typeof TransactionStatusEnum[keyof typeof Tr export type TransactionContent = EthereumTransaction; /** - * + * * @export * @enum {string} */ @@ -3511,13 +3536,14 @@ export interface Transfer { */ 'amount': string; /** - * The ID of the asset being transferred + * The ID of the asset being transferred. Use `asset.asset_id` instead. * @type {string} * @memberof Transfer + * @deprecated */ 'asset_id': string; /** - * + * * @type {Asset} * @memberof Transfer */ @@ -3529,13 +3555,13 @@ export interface Transfer { */ 'transfer_id': string; /** - * + * * @type {Transaction} * @memberof Transfer */ 'transaction'?: Transaction; /** - * + * * @type {SponsoredSend} * @memberof Transfer */ @@ -3544,26 +3570,30 @@ export interface Transfer { * The unsigned payload of the transfer. This is the payload that needs to be signed by the sender. * @type {string} * @memberof Transfer + * @deprecated */ 'unsigned_payload'?: string; /** * The signed payload of the transfer. This is the payload that has been signed by the sender. * @type {string} * @memberof Transfer + * @deprecated */ 'signed_payload'?: string; /** * The hash of the transfer transaction * @type {string} * @memberof Transfer + * @deprecated */ 'transaction_hash'?: string; /** - * The status of the transfer + * * @type {string} * @memberof Transfer + * @deprecated */ - 'status'?: TransferStatusEnum; + 'status'?: string; /** * Whether the transfer uses sponsored gas * @type {boolean} @@ -3571,24 +3601,14 @@ export interface Transfer { */ 'gasless': boolean; } - -export const TransferStatusEnum = { - Pending: 'pending', - Broadcast: 'broadcast', - Complete: 'complete', - Failed: 'failed' -} as const; - -export type TransferStatusEnum = typeof TransferStatusEnum[keyof typeof TransferStatusEnum]; - /** - * + * * @export * @interface TransferList */ export interface TransferList { /** - * + * * @type {Array} * @memberof TransferList */ @@ -3613,13 +3633,32 @@ export interface TransferList { 'total_count': number; } /** - * + * Smart Contract data to be updated + * @export + * @interface UpdateSmartContractRequest + */ +export interface UpdateSmartContractRequest { + /** + * ABI of the smart contract + * @type {string} + * @memberof UpdateSmartContractRequest + */ + 'abi'?: string; + /** + * Name of the smart contract + * @type {string} + * @memberof UpdateSmartContractRequest + */ + 'contract_name'?: string; +} +/** + * * @export * @interface UpdateWebhookRequest */ export interface UpdateWebhookRequest { /** - * + * * @type {WebhookEventTypeFilter} * @memberof UpdateWebhookRequest */ @@ -3638,7 +3677,7 @@ export interface UpdateWebhookRequest { 'notification_uri'?: string; } /** - * + * * @export * @interface User */ @@ -3650,7 +3689,7 @@ export interface User { */ 'id': string; /** - * + * * @type {string} * @memberof User */ @@ -3681,13 +3720,13 @@ export interface Validator { */ 'asset_id': string; /** - * + * * @type {ValidatorStatus} * @memberof Validator */ 'status': ValidatorStatus; /** - * + * * @type {ValidatorDetails} * @memberof Validator */ @@ -3702,13 +3741,13 @@ export interface Validator { export type ValidatorDetails = EthereumValidatorMetadata; /** - * + * * @export * @interface ValidatorList */ export interface ValidatorList { /** - * + * * @type {Array} * @memberof ValidatorList */ @@ -3752,7 +3791,7 @@ export type ValidatorStatus = typeof ValidatorStatus[keyof typeof ValidatorStatu /** - * + * * @export * @interface Wallet */ @@ -3770,13 +3809,13 @@ export interface Wallet { */ 'network_id': string; /** - * + * * @type {Address} * @memberof Wallet */ 'default_address'?: Address; /** - * + * * @type {FeatureSet} * @memberof Wallet */ @@ -3803,7 +3842,7 @@ export type WalletServerSignerStatusEnum = typeof WalletServerSignerStatusEnum[k */ export interface WalletList { /** - * + * * @type {Array} * @memberof WalletList */ @@ -3846,13 +3885,13 @@ export interface Webhook { */ 'network_id'?: string; /** - * + * * @type {WebhookEventType} * @memberof Webhook */ 'event_type'?: WebhookEventType; /** - * + * * @type {WebhookEventTypeFilter} * @memberof Webhook */ @@ -3916,7 +3955,7 @@ export interface WebhookEventFilter { 'to_address'?: string; } /** - * + * * @export * @enum {string} */ @@ -3940,13 +3979,13 @@ export type WebhookEventType = typeof WebhookEventType[keyof typeof WebhookEvent export type WebhookEventTypeFilter = WebhookSmartContractEventFilter | WebhookWalletActivityFilter; /** - * + * * @export * @interface WebhookList */ export interface WebhookList { /** - * + * * @type {Array} * @memberof WebhookList */ @@ -3965,7 +4004,7 @@ export interface WebhookList { 'next_page'?: string; } /** - * Filter for smart contract events. This filter allows the client to specify smart contract addresses to monitor for activities such as contract function calls. + * Filter for smart contract events. This filter allows the client to specify smart contract addresses to monitor for activities such as contract function calls. * @export * @interface WebhookSmartContractEventFilter */ @@ -3978,7 +4017,7 @@ export interface WebhookSmartContractEventFilter { 'contract_addresses': Array; } /** - * Filter for wallet activity events. This filter allows the client to specify one or more wallet addresses to monitor for activities such as transactions, transfers, or other types of events that are associated with the specified addresses. + * Filter for wallet activity events. This filter allows the client to specify one or more wallet addresses to monitor for activities such as transactions, transfers, or other types of events that are associated with the specified addresses. * @export * @interface WebhookWalletActivityFilter */ @@ -3994,7 +4033,7 @@ export interface WebhookWalletActivityFilter { * @type {string} * @memberof WebhookWalletActivityFilter */ - 'wallet_id'?: string; + 'wallet_id': string; } /** @@ -4007,7 +4046,7 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura * Create a new address scoped to the wallet. * @summary Create a new address * @param {string} walletId The ID of the wallet to create the address in. - * @param {CreateAddressRequest} [createAddressRequest] + * @param {CreateAddressRequest} [createAddressRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4027,8 +4066,11 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -4046,7 +4088,7 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura * @summary Create a new payload signature. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address of the address to sign the payload with. - * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] + * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4069,8 +4111,11 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -4110,8 +4155,14 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4152,8 +4203,14 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4194,8 +4251,14 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4233,12 +4296,18 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (page !== undefined) { localVarQueryParameter['page'] = page; } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4273,6 +4342,12 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -4282,7 +4357,7 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4321,6 +4396,12 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -4330,7 +4411,7 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4369,12 +4450,15 @@ export const AddressesApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (assetId !== undefined) { localVarQueryParameter['asset_id'] = assetId; } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4398,7 +4482,7 @@ export const AddressesApiFp = function(configuration?: Configuration) { * Create a new address scoped to the wallet. * @summary Create a new address * @param {string} walletId The ID of the wallet to create the address in. - * @param {CreateAddressRequest} [createAddressRequest] + * @param {CreateAddressRequest} [createAddressRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4413,7 +4497,7 @@ export const AddressesApiFp = function(configuration?: Configuration) { * @summary Create a new payload signature. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address of the address to sign the payload with. - * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] + * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4543,7 +4627,7 @@ export const AddressesApiFactory = function (configuration?: Configuration, base * Create a new address scoped to the wallet. * @summary Create a new address * @param {string} walletId The ID of the wallet to create the address in. - * @param {CreateAddressRequest} [createAddressRequest] + * @param {CreateAddressRequest} [createAddressRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4555,7 +4639,7 @@ export const AddressesApiFactory = function (configuration?: Configuration, base * @summary Create a new payload signature. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address of the address to sign the payload with. - * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] + * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -4660,7 +4744,7 @@ export interface AddressesApiInterface { * Create a new address scoped to the wallet. * @summary Create a new address * @param {string} walletId The ID of the wallet to create the address in. - * @param {CreateAddressRequest} [createAddressRequest] + * @param {CreateAddressRequest} [createAddressRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApiInterface @@ -4672,7 +4756,7 @@ export interface AddressesApiInterface { * @summary Create a new payload signature. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address of the address to sign the payload with. - * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] + * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApiInterface @@ -4777,7 +4861,7 @@ export class AddressesApi extends BaseAPI implements AddressesApiInterface { * Create a new address scoped to the wallet. * @summary Create a new address * @param {string} walletId The ID of the wallet to create the address in. - * @param {CreateAddressRequest} [createAddressRequest] + * @param {CreateAddressRequest} [createAddressRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi @@ -4791,7 +4875,7 @@ export class AddressesApi extends BaseAPI implements AddressesApiInterface { * @summary Create a new payload signature. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address of the address to sign the payload with. - * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] + * @param {CreatePayloadSignatureRequest} [createPayloadSignatureRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AddressesApi @@ -4935,8 +5019,14 @@ export const AssetsApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5075,6 +5165,12 @@ export const BalanceHistoryApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -5084,7 +5180,7 @@ export const BalanceHistoryApiAxiosParamCreator = function (configuration?: Conf } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5245,6 +5341,12 @@ export const ContractEventsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (protocolName !== undefined) { localVarQueryParameter['protocol_name'] = protocolName; } @@ -5270,7 +5372,7 @@ export const ContractEventsApiAxiosParamCreator = function (configuration?: Conf } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5406,7 +5508,7 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the contract invocation belongs to. * @param {string} contractInvocationId The ID of the contract invocation to broadcast. - * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest + * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5434,8 +5536,11 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -5453,7 +5558,7 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: * @summary Create a new contract invocation for an address. * @param {string} walletId The ID of the wallet the source address belongs to. * @param {string} addressId The ID of the address to invoke the contract from. - * @param {CreateContractInvocationRequest} createContractInvocationRequest + * @param {CreateContractInvocationRequest} createContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5478,8 +5583,11 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -5523,8 +5631,14 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5563,6 +5677,12 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -5572,7 +5692,7 @@ export const ContractInvocationsApiAxiosParamCreator = function (configuration?: } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5598,7 +5718,7 @@ export const ContractInvocationsApiFp = function(configuration?: Configuration) * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the contract invocation belongs to. * @param {string} contractInvocationId The ID of the contract invocation to broadcast. - * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest + * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5613,7 +5733,7 @@ export const ContractInvocationsApiFp = function(configuration?: Configuration) * @summary Create a new contract invocation for an address. * @param {string} walletId The ID of the wallet the source address belongs to. * @param {string} addressId The ID of the address to invoke the contract from. - * @param {CreateContractInvocationRequest} createContractInvocationRequest + * @param {CreateContractInvocationRequest} createContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5670,7 +5790,7 @@ export const ContractInvocationsApiFactory = function (configuration?: Configura * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the contract invocation belongs to. * @param {string} contractInvocationId The ID of the contract invocation to broadcast. - * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest + * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5682,7 +5802,7 @@ export const ContractInvocationsApiFactory = function (configuration?: Configura * @summary Create a new contract invocation for an address. * @param {string} walletId The ID of the wallet the source address belongs to. * @param {string} addressId The ID of the address to invoke the contract from. - * @param {CreateContractInvocationRequest} createContractInvocationRequest + * @param {CreateContractInvocationRequest} createContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -5729,7 +5849,7 @@ export interface ContractInvocationsApiInterface { * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the contract invocation belongs to. * @param {string} contractInvocationId The ID of the contract invocation to broadcast. - * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest + * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ContractInvocationsApiInterface @@ -5741,7 +5861,7 @@ export interface ContractInvocationsApiInterface { * @summary Create a new contract invocation for an address. * @param {string} walletId The ID of the wallet the source address belongs to. * @param {string} addressId The ID of the address to invoke the contract from. - * @param {CreateContractInvocationRequest} createContractInvocationRequest + * @param {CreateContractInvocationRequest} createContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ContractInvocationsApiInterface @@ -5788,7 +5908,7 @@ export class ContractInvocationsApi extends BaseAPI implements ContractInvocatio * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the contract invocation belongs to. * @param {string} contractInvocationId The ID of the contract invocation to broadcast. - * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest + * @param {BroadcastContractInvocationRequest} broadcastContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ContractInvocationsApi @@ -5802,7 +5922,7 @@ export class ContractInvocationsApi extends BaseAPI implements ContractInvocatio * @summary Create a new contract invocation for an address. * @param {string} walletId The ID of the wallet the source address belongs to. * @param {string} addressId The ID of the address to invoke the contract from. - * @param {CreateContractInvocationRequest} createContractInvocationRequest + * @param {CreateContractInvocationRequest} createContractInvocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ContractInvocationsApi @@ -5880,8 +6000,14 @@ export const ExternalAddressesApiAxiosParamCreator = function (configuration?: C const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5922,8 +6048,14 @@ export const ExternalAddressesApiAxiosParamCreator = function (configuration?: C const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5961,12 +6093,18 @@ export const ExternalAddressesApiAxiosParamCreator = function (configuration?: C const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (page !== undefined) { localVarQueryParameter['page'] = page; } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6005,6 +6143,12 @@ export const ExternalAddressesApiAxiosParamCreator = function (configuration?: C const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (assetId !== undefined) { localVarQueryParameter['asset_id'] = assetId; } @@ -6014,7 +6158,7 @@ export const ExternalAddressesApiAxiosParamCreator = function (configuration?: C } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6292,7 +6436,7 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) * @summary Create a new fund operation. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundOperationRequest} createFundOperationRequest + * @param {CreateFundOperationRequest} createFundOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6317,8 +6461,11 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -6336,7 +6483,7 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) * @summary Create a Fund Operation quote. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundQuoteRequest} createFundQuoteRequest + * @param {CreateFundQuoteRequest} createFundQuoteRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6361,8 +6508,11 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -6406,8 +6556,14 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6446,6 +6602,12 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -6455,7 +6617,7 @@ export const FundApiAxiosParamCreator = function (configuration?: Configuration) } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6480,7 +6642,7 @@ export const FundApiFp = function(configuration?: Configuration) { * @summary Create a new fund operation. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundOperationRequest} createFundOperationRequest + * @param {CreateFundOperationRequest} createFundOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6495,7 +6657,7 @@ export const FundApiFp = function(configuration?: Configuration) { * @summary Create a Fund Operation quote. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundQuoteRequest} createFundQuoteRequest + * @param {CreateFundQuoteRequest} createFundQuoteRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6551,7 +6713,7 @@ export const FundApiFactory = function (configuration?: Configuration, basePath? * @summary Create a new fund operation. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundOperationRequest} createFundOperationRequest + * @param {CreateFundOperationRequest} createFundOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6563,7 +6725,7 @@ export const FundApiFactory = function (configuration?: Configuration, basePath? * @summary Create a Fund Operation quote. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundQuoteRequest} createFundQuoteRequest + * @param {CreateFundQuoteRequest} createFundQuoteRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6609,7 +6771,7 @@ export interface FundApiInterface { * @summary Create a new fund operation. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundOperationRequest} createFundOperationRequest + * @param {CreateFundOperationRequest} createFundOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof FundApiInterface @@ -6621,7 +6783,7 @@ export interface FundApiInterface { * @summary Create a Fund Operation quote. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundQuoteRequest} createFundQuoteRequest + * @param {CreateFundQuoteRequest} createFundQuoteRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof FundApiInterface @@ -6667,7 +6829,7 @@ export class FundApi extends BaseAPI implements FundApiInterface { * @summary Create a new fund operation. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundOperationRequest} createFundOperationRequest + * @param {CreateFundOperationRequest} createFundOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof FundApi @@ -6681,7 +6843,7 @@ export class FundApi extends BaseAPI implements FundApiInterface { * @summary Create a Fund Operation quote. * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The onchain address to be funded. - * @param {CreateFundQuoteRequest} createFundQuoteRequest + * @param {CreateFundQuoteRequest} createFundQuoteRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof FundApi @@ -6734,7 +6896,7 @@ export const MPCWalletStakeApiAxiosParamCreator = function (configuration?: Conf * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the staking operation belongs to. * @param {string} stakingOperationId The ID of the staking operation to broadcast. - * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest + * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6762,8 +6924,11 @@ export const MPCWalletStakeApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -6781,7 +6946,7 @@ export const MPCWalletStakeApiAxiosParamCreator = function (configuration?: Conf * @summary Create a new staking operation for an address * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to create the staking operation for. - * @param {CreateStakingOperationRequest} createStakingOperationRequest + * @param {CreateStakingOperationRequest} createStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6806,8 +6971,11 @@ export const MPCWalletStakeApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -6851,8 +7019,14 @@ export const MPCWalletStakeApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6878,7 +7052,7 @@ export const MPCWalletStakeApiFp = function(configuration?: Configuration) { * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the staking operation belongs to. * @param {string} stakingOperationId The ID of the staking operation to broadcast. - * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest + * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6893,7 +7067,7 @@ export const MPCWalletStakeApiFp = function(configuration?: Configuration) { * @summary Create a new staking operation for an address * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to create the staking operation for. - * @param {CreateStakingOperationRequest} createStakingOperationRequest + * @param {CreateStakingOperationRequest} createStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6934,7 +7108,7 @@ export const MPCWalletStakeApiFactory = function (configuration?: Configuration, * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the staking operation belongs to. * @param {string} stakingOperationId The ID of the staking operation to broadcast. - * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest + * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6946,7 +7120,7 @@ export const MPCWalletStakeApiFactory = function (configuration?: Configuration, * @summary Create a new staking operation for an address * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to create the staking operation for. - * @param {CreateStakingOperationRequest} createStakingOperationRequest + * @param {CreateStakingOperationRequest} createStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6980,7 +7154,7 @@ export interface MPCWalletStakeApiInterface { * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the staking operation belongs to. * @param {string} stakingOperationId The ID of the staking operation to broadcast. - * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest + * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof MPCWalletStakeApiInterface @@ -6992,7 +7166,7 @@ export interface MPCWalletStakeApiInterface { * @summary Create a new staking operation for an address * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to create the staking operation for. - * @param {CreateStakingOperationRequest} createStakingOperationRequest + * @param {CreateStakingOperationRequest} createStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof MPCWalletStakeApiInterface @@ -7026,7 +7200,7 @@ export class MPCWalletStakeApi extends BaseAPI implements MPCWalletStakeApiInter * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address the staking operation belongs to. * @param {string} stakingOperationId The ID of the staking operation to broadcast. - * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest + * @param {BroadcastStakingOperationRequest} broadcastStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof MPCWalletStakeApi @@ -7040,7 +7214,7 @@ export class MPCWalletStakeApi extends BaseAPI implements MPCWalletStakeApiInter * @summary Create a new staking operation for an address * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to create the staking operation for. - * @param {CreateStakingOperationRequest} createStakingOperationRequest + * @param {CreateStakingOperationRequest} createStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof MPCWalletStakeApi @@ -7095,8 +7269,14 @@ export const NetworksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7228,6 +7408,12 @@ export const OnchainIdentityApiAxiosParamCreator = function (configuration?: Con const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (roles) { localVarQueryParameter['roles'] = roles.join(COLLECTION_FORMATS.csv); } @@ -7241,7 +7427,7 @@ export const OnchainIdentityApiAxiosParamCreator = function (configuration?: Con } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7394,46 +7580,14 @@ export const ReputationApiAxiosParamCreator = function (configuration?: Configur const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Get the risk of an address - * @summary Get the risk of an address - * @param {string} networkId The ID of the blockchain network. - * @param {string} addressId The ID of the address to fetch the risk for. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getAddressRisk: async (networkId: string, addressId: string, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'networkId' is not null or undefined - assertParamExists('getAddressRisk', 'networkId', networkId) - // verify required parameter 'addressId' is not null or undefined - assertParamExists('getAddressRisk', 'addressId', addressId) - const localVarPath = `/v1/networks/{network_id}/addresses/{address_id}/risk` - .replace(`{${"network_id"}}`, encodeURIComponent(String(networkId))) - .replace(`{${"address_id"}}`, encodeURIComponent(String(addressId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7467,20 +7621,6 @@ export const ReputationApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['ReputationApi.getAddressReputation']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, - /** - * Get the risk of an address - * @summary Get the risk of an address - * @param {string} networkId The ID of the blockchain network. - * @param {string} addressId The ID of the address to fetch the risk for. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getAddressRisk(networkId: string, addressId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getAddressRisk(networkId, addressId, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ReputationApi.getAddressRisk']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, } }; @@ -7502,17 +7642,6 @@ export const ReputationApiFactory = function (configuration?: Configuration, bas getAddressReputation(networkId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getAddressReputation(networkId, addressId, options).then((request) => request(axios, basePath)); }, - /** - * Get the risk of an address - * @summary Get the risk of an address - * @param {string} networkId The ID of the blockchain network. - * @param {string} addressId The ID of the address to fetch the risk for. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getAddressRisk(networkId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.getAddressRisk(networkId, addressId, options).then((request) => request(axios, basePath)); - }, }; }; @@ -7533,17 +7662,6 @@ export interface ReputationApiInterface { */ getAddressReputation(networkId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise; - /** - * Get the risk of an address - * @summary Get the risk of an address - * @param {string} networkId The ID of the blockchain network. - * @param {string} addressId The ID of the address to fetch the risk for. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ReputationApiInterface - */ - getAddressRisk(networkId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise; - } /** @@ -7565,19 +7683,6 @@ export class ReputationApi extends BaseAPI implements ReputationApiInterface { public getAddressReputation(networkId: string, addressId: string, options?: RawAxiosRequestConfig) { return ReputationApiFp(this.configuration).getAddressReputation(networkId, addressId, options).then((request) => request(this.axios, this.basePath)); } - - /** - * Get the risk of an address - * @summary Get the risk of an address - * @param {string} networkId The ID of the blockchain network. - * @param {string} addressId The ID of the address to fetch the risk for. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ReputationApi - */ - public getAddressRisk(networkId: string, addressId: string, options?: RawAxiosRequestConfig) { - return ReputationApiFp(this.configuration).getAddressRisk(networkId, addressId, options).then((request) => request(this.axios, this.basePath)); - } } @@ -7591,7 +7696,7 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi /** * Create a new Server-Signer * @summary Create a new Server-Signer - * @param {CreateServerSignerRequest} [createServerSignerRequest] + * @param {CreateServerSignerRequest} [createServerSignerRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7608,8 +7713,11 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -7645,8 +7753,14 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7682,6 +7796,9 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -7691,7 +7808,7 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7722,6 +7839,12 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -7731,7 +7854,7 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7745,7 +7868,7 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SeedCreationEventResult} [seedCreationEventResult] + * @param {SeedCreationEventResult} [seedCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7765,8 +7888,11 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -7783,7 +7909,7 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SignatureCreationEventResult} [signatureCreationEventResult] + * @param {SignatureCreationEventResult} [signatureCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7803,8 +7929,11 @@ export const ServerSignersApiAxiosParamCreator = function (configuration?: Confi const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -7830,7 +7959,7 @@ export const ServerSignersApiFp = function(configuration?: Configuration) { /** * Create a new Server-Signer * @summary Create a new Server-Signer - * @param {CreateServerSignerRequest} [createServerSignerRequest] + * @param {CreateServerSignerRequest} [createServerSignerRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7887,7 +8016,7 @@ export const ServerSignersApiFp = function(configuration?: Configuration) { * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SeedCreationEventResult} [seedCreationEventResult] + * @param {SeedCreationEventResult} [seedCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7901,7 +8030,7 @@ export const ServerSignersApiFp = function(configuration?: Configuration) { * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SignatureCreationEventResult} [signatureCreationEventResult] + * @param {SignatureCreationEventResult} [signatureCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7924,7 +8053,7 @@ export const ServerSignersApiFactory = function (configuration?: Configuration, /** * Create a new Server-Signer * @summary Create a new Server-Signer - * @param {CreateServerSignerRequest} [createServerSignerRequest] + * @param {CreateServerSignerRequest} [createServerSignerRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7969,7 +8098,7 @@ export const ServerSignersApiFactory = function (configuration?: Configuration, * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SeedCreationEventResult} [seedCreationEventResult] + * @param {SeedCreationEventResult} [seedCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7980,7 +8109,7 @@ export const ServerSignersApiFactory = function (configuration?: Configuration, * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SignatureCreationEventResult} [signatureCreationEventResult] + * @param {SignatureCreationEventResult} [signatureCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -7999,7 +8128,7 @@ export interface ServerSignersApiInterface { /** * Create a new Server-Signer * @summary Create a new Server-Signer - * @param {CreateServerSignerRequest} [createServerSignerRequest] + * @param {CreateServerSignerRequest} [createServerSignerRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApiInterface @@ -8044,7 +8173,7 @@ export interface ServerSignersApiInterface { * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SeedCreationEventResult} [seedCreationEventResult] + * @param {SeedCreationEventResult} [seedCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApiInterface @@ -8055,7 +8184,7 @@ export interface ServerSignersApiInterface { * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SignatureCreationEventResult} [signatureCreationEventResult] + * @param {SignatureCreationEventResult} [signatureCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApiInterface @@ -8074,7 +8203,7 @@ export class ServerSignersApi extends BaseAPI implements ServerSignersApiInterfa /** * Create a new Server-Signer * @summary Create a new Server-Signer - * @param {CreateServerSignerRequest} [createServerSignerRequest] + * @param {CreateServerSignerRequest} [createServerSignerRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApi @@ -8127,7 +8256,7 @@ export class ServerSignersApi extends BaseAPI implements ServerSignersApiInterfa * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SeedCreationEventResult} [seedCreationEventResult] + * @param {SeedCreationEventResult} [seedCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApi @@ -8140,7 +8269,7 @@ export class ServerSignersApi extends BaseAPI implements ServerSignersApiInterfa * Submit the result of a server signer event * @summary Submit the result of a server signer event * @param {string} serverSignerId The ID of the server signer to submit the event result for - * @param {SignatureCreationEventResult} [signatureCreationEventResult] + * @param {SignatureCreationEventResult} [signatureCreationEventResult] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ServerSignersApi @@ -8163,7 +8292,7 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf * @summary Create a new smart contract * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to deploy the smart contract from. - * @param {CreateSmartContractRequest} createSmartContractRequest + * @param {CreateSmartContractRequest} createSmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8188,8 +8317,11 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8208,7 +8340,7 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to broadcast the transaction from. * @param {string} smartContractId The UUID of the smart contract to broadcast the transaction to. - * @param {DeploySmartContractRequest} deploySmartContractRequest + * @param {DeploySmartContractRequest} deploySmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8236,8 +8368,11 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8281,8 +8416,14 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8293,21 +8434,14 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf }; }, /** - * List all smart contracts deployed by address. - * @summary List smart contracts deployed by address - * @param {string} walletId The ID of the wallet the address belongs to. - * @param {string} addressId The ID of the address to fetch the smart contracts for. + * List smart contracts + * @summary List smart contracts + * @param {string} [page] Pagination token for retrieving the next set of results * @param {*} [options] Override http request option. * @throws {RequiredError} */ - listSmartContracts: async (walletId: string, addressId: string, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'walletId' is not null or undefined - assertParamExists('listSmartContracts', 'walletId', walletId) - // verify required parameter 'addressId' is not null or undefined - assertParamExists('listSmartContracts', 'addressId', addressId) - const localVarPath = `/v1/wallets/{wallet_id}/addresses/{address_id}/smart_contracts` - .replace(`{${"wallet_id"}}`, encodeURIComponent(String(walletId))) - .replace(`{${"address_id"}}`, encodeURIComponent(String(addressId))); + listSmartContracts: async (page?: string, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/v1/smart_contracts`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -8319,8 +8453,18 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + if (page !== undefined) { + localVarQueryParameter['page'] = page; + } + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8333,9 +8477,9 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf /** * Perform a read operation on a smart contract without creating a transaction * @summary Read data from a smart contract - * @param {string} networkId - * @param {string} contractAddress - * @param {ReadContractRequest} readContractRequest + * @param {string} networkId + * @param {string} contractAddress + * @param {ReadContractRequest} readContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8360,8 +8504,14 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8369,6 +8519,102 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(readContractRequest, localVarRequestOptions, configuration) + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Register a smart contract + * @summary Register a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + registerSmartContract: async (networkId: string, contractAddress: string, registerSmartContractRequest?: RegisterSmartContractRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'networkId' is not null or undefined + assertParamExists('registerSmartContract', 'networkId', networkId) + // verify required parameter 'contractAddress' is not null or undefined + assertParamExists('registerSmartContract', 'contractAddress', contractAddress) + const localVarPath = `/v1/networks/{network_id}/smart_contracts/{contract_address}/register` + .replace(`{${"network_id"}}`, encodeURIComponent(String(networkId))) + .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(registerSmartContractRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Update a smart contract + * @summary Update a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateSmartContract: async (networkId: string, contractAddress: string, updateSmartContractRequest?: UpdateSmartContractRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'networkId' is not null or undefined + assertParamExists('updateSmartContract', 'networkId', networkId) + // verify required parameter 'contractAddress' is not null or undefined + assertParamExists('updateSmartContract', 'contractAddress', contractAddress) + const localVarPath = `/v1/networks/{network_id}/smart_contracts/{contract_address}` + .replace(`{${"network_id"}}`, encodeURIComponent(String(networkId))) + .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(updateSmartContractRequest, localVarRequestOptions, configuration) + return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, @@ -8389,7 +8635,7 @@ export const SmartContractsApiFp = function(configuration?: Configuration) { * @summary Create a new smart contract * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to deploy the smart contract from. - * @param {CreateSmartContractRequest} createSmartContractRequest + * @param {CreateSmartContractRequest} createSmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8405,7 +8651,7 @@ export const SmartContractsApiFp = function(configuration?: Configuration) { * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to broadcast the transaction from. * @param {string} smartContractId The UUID of the smart contract to broadcast the transaction to. - * @param {DeploySmartContractRequest} deploySmartContractRequest + * @param {DeploySmartContractRequest} deploySmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8431,15 +8677,14 @@ export const SmartContractsApiFp = function(configuration?: Configuration) { return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** - * List all smart contracts deployed by address. - * @summary List smart contracts deployed by address - * @param {string} walletId The ID of the wallet the address belongs to. - * @param {string} addressId The ID of the address to fetch the smart contracts for. + * List smart contracts + * @summary List smart contracts + * @param {string} [page] Pagination token for retrieving the next set of results * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async listSmartContracts(walletId: string, addressId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.listSmartContracts(walletId, addressId, options); + async listSmartContracts(page?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listSmartContracts(page, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap['SmartContractsApi.listSmartContracts']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); @@ -8447,9 +8692,9 @@ export const SmartContractsApiFp = function(configuration?: Configuration) { /** * Perform a read operation on a smart contract without creating a transaction * @summary Read data from a smart contract - * @param {string} networkId - * @param {string} contractAddress - * @param {ReadContractRequest} readContractRequest + * @param {string} networkId + * @param {string} contractAddress + * @param {ReadContractRequest} readContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8459,6 +8704,36 @@ export const SmartContractsApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['SmartContractsApi.readContract']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, + /** + * Register a smart contract + * @summary Register a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async registerSmartContract(networkId: string, contractAddress: string, registerSmartContractRequest?: RegisterSmartContractRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.registerSmartContract(networkId, contractAddress, registerSmartContractRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SmartContractsApi.registerSmartContract']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Update a smart contract + * @summary Update a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updateSmartContract(networkId: string, contractAddress: string, updateSmartContractRequest?: UpdateSmartContractRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updateSmartContract(networkId, contractAddress, updateSmartContractRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SmartContractsApi.updateSmartContract']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, } }; @@ -8474,7 +8749,7 @@ export const SmartContractsApiFactory = function (configuration?: Configuration, * @summary Create a new smart contract * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to deploy the smart contract from. - * @param {CreateSmartContractRequest} createSmartContractRequest + * @param {CreateSmartContractRequest} createSmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8487,7 +8762,7 @@ export const SmartContractsApiFactory = function (configuration?: Configuration, * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to broadcast the transaction from. * @param {string} smartContractId The UUID of the smart contract to broadcast the transaction to. - * @param {DeploySmartContractRequest} deploySmartContractRequest + * @param {DeploySmartContractRequest} deploySmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8507,28 +8782,51 @@ export const SmartContractsApiFactory = function (configuration?: Configuration, return localVarFp.getSmartContract(walletId, addressId, smartContractId, options).then((request) => request(axios, basePath)); }, /** - * List all smart contracts deployed by address. - * @summary List smart contracts deployed by address - * @param {string} walletId The ID of the wallet the address belongs to. - * @param {string} addressId The ID of the address to fetch the smart contracts for. + * List smart contracts + * @summary List smart contracts + * @param {string} [page] Pagination token for retrieving the next set of results * @param {*} [options] Override http request option. * @throws {RequiredError} */ - listSmartContracts(walletId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.listSmartContracts(walletId, addressId, options).then((request) => request(axios, basePath)); + listSmartContracts(page?: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.listSmartContracts(page, options).then((request) => request(axios, basePath)); }, /** * Perform a read operation on a smart contract without creating a transaction * @summary Read data from a smart contract - * @param {string} networkId - * @param {string} contractAddress - * @param {ReadContractRequest} readContractRequest + * @param {string} networkId + * @param {string} contractAddress + * @param {ReadContractRequest} readContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ readContract(networkId: string, contractAddress: string, readContractRequest: ReadContractRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.readContract(networkId, contractAddress, readContractRequest, options).then((request) => request(axios, basePath)); }, + /** + * Register a smart contract + * @summary Register a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + registerSmartContract(networkId: string, contractAddress: string, registerSmartContractRequest?: RegisterSmartContractRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.registerSmartContract(networkId, contractAddress, registerSmartContractRequest, options).then((request) => request(axios, basePath)); + }, + /** + * Update a smart contract + * @summary Update a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateSmartContract(networkId: string, contractAddress: string, updateSmartContractRequest?: UpdateSmartContractRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.updateSmartContract(networkId, contractAddress, updateSmartContractRequest, options).then((request) => request(axios, basePath)); + }, }; }; @@ -8543,7 +8841,7 @@ export interface SmartContractsApiInterface { * @summary Create a new smart contract * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to deploy the smart contract from. - * @param {CreateSmartContractRequest} createSmartContractRequest + * @param {CreateSmartContractRequest} createSmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApiInterface @@ -8556,7 +8854,7 @@ export interface SmartContractsApiInterface { * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to broadcast the transaction from. * @param {string} smartContractId The UUID of the smart contract to broadcast the transaction to. - * @param {DeploySmartContractRequest} deploySmartContractRequest + * @param {DeploySmartContractRequest} deploySmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApiInterface @@ -8576,28 +8874,51 @@ export interface SmartContractsApiInterface { getSmartContract(walletId: string, addressId: string, smartContractId: string, options?: RawAxiosRequestConfig): AxiosPromise; /** - * List all smart contracts deployed by address. - * @summary List smart contracts deployed by address - * @param {string} walletId The ID of the wallet the address belongs to. - * @param {string} addressId The ID of the address to fetch the smart contracts for. + * List smart contracts + * @summary List smart contracts + * @param {string} [page] Pagination token for retrieving the next set of results * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApiInterface */ - listSmartContracts(walletId: string, addressId: string, options?: RawAxiosRequestConfig): AxiosPromise; + listSmartContracts(page?: string, options?: RawAxiosRequestConfig): AxiosPromise; /** * Perform a read operation on a smart contract without creating a transaction * @summary Read data from a smart contract - * @param {string} networkId - * @param {string} contractAddress - * @param {ReadContractRequest} readContractRequest + * @param {string} networkId + * @param {string} contractAddress + * @param {ReadContractRequest} readContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApiInterface */ readContract(networkId: string, contractAddress: string, readContractRequest: ReadContractRequest, options?: RawAxiosRequestConfig): AxiosPromise; + /** + * Register a smart contract + * @summary Register a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SmartContractsApiInterface + */ + registerSmartContract(networkId: string, contractAddress: string, registerSmartContractRequest?: RegisterSmartContractRequest, options?: RawAxiosRequestConfig): AxiosPromise; + + /** + * Update a smart contract + * @summary Update a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SmartContractsApiInterface + */ + updateSmartContract(networkId: string, contractAddress: string, updateSmartContractRequest?: UpdateSmartContractRequest, options?: RawAxiosRequestConfig): AxiosPromise; + } /** @@ -8612,7 +8933,7 @@ export class SmartContractsApi extends BaseAPI implements SmartContractsApiInter * @summary Create a new smart contract * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to deploy the smart contract from. - * @param {CreateSmartContractRequest} createSmartContractRequest + * @param {CreateSmartContractRequest} createSmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApi @@ -8627,7 +8948,7 @@ export class SmartContractsApi extends BaseAPI implements SmartContractsApiInter * @param {string} walletId The ID of the wallet the address belongs to. * @param {string} addressId The ID of the address to broadcast the transaction from. * @param {string} smartContractId The UUID of the smart contract to broadcast the transaction to. - * @param {DeploySmartContractRequest} deploySmartContractRequest + * @param {DeploySmartContractRequest} deploySmartContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApi @@ -8651,24 +8972,23 @@ export class SmartContractsApi extends BaseAPI implements SmartContractsApiInter } /** - * List all smart contracts deployed by address. - * @summary List smart contracts deployed by address - * @param {string} walletId The ID of the wallet the address belongs to. - * @param {string} addressId The ID of the address to fetch the smart contracts for. + * List smart contracts + * @summary List smart contracts + * @param {string} [page] Pagination token for retrieving the next set of results * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApi */ - public listSmartContracts(walletId: string, addressId: string, options?: RawAxiosRequestConfig) { - return SmartContractsApiFp(this.configuration).listSmartContracts(walletId, addressId, options).then((request) => request(this.axios, this.basePath)); + public listSmartContracts(page?: string, options?: RawAxiosRequestConfig) { + return SmartContractsApiFp(this.configuration).listSmartContracts(page, options).then((request) => request(this.axios, this.basePath)); } /** * Perform a read operation on a smart contract without creating a transaction * @summary Read data from a smart contract - * @param {string} networkId - * @param {string} contractAddress - * @param {ReadContractRequest} readContractRequest + * @param {string} networkId + * @param {string} contractAddress + * @param {ReadContractRequest} readContractRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SmartContractsApi @@ -8676,6 +8996,34 @@ export class SmartContractsApi extends BaseAPI implements SmartContractsApiInter public readContract(networkId: string, contractAddress: string, readContractRequest: ReadContractRequest, options?: RawAxiosRequestConfig) { return SmartContractsApiFp(this.configuration).readContract(networkId, contractAddress, readContractRequest, options).then((request) => request(this.axios, this.basePath)); } + + /** + * Register a smart contract + * @summary Register a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SmartContractsApi + */ + public registerSmartContract(networkId: string, contractAddress: string, registerSmartContractRequest?: RegisterSmartContractRequest, options?: RawAxiosRequestConfig) { + return SmartContractsApiFp(this.configuration).registerSmartContract(networkId, contractAddress, registerSmartContractRequest, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Update a smart contract + * @summary Update a smart contract + * @param {string} networkId The ID of the network to fetch. + * @param {string} contractAddress EVM address of the smart contract (42 characters, including \'0x\', in lowercase) + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SmartContractsApi + */ + public updateSmartContract(networkId: string, contractAddress: string, updateSmartContractRequest?: UpdateSmartContractRequest, options?: RawAxiosRequestConfig) { + return SmartContractsApiFp(this.configuration).updateSmartContract(networkId, contractAddress, updateSmartContractRequest, options).then((request) => request(this.axios, this.basePath)); + } } @@ -8689,7 +9037,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration /** * Build a new staking operation * @summary Build a new staking operation - * @param {BuildStakingOperationRequest} buildStakingOperationRequest + * @param {BuildStakingOperationRequest} buildStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8708,8 +9056,14 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8760,6 +9114,12 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -8785,7 +9145,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8798,7 +9158,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration /** * Fetch staking rewards for a list of addresses * @summary Fetch staking rewards - * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest + * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest * @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50. * @param {string} [page] A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] Override http request option. @@ -8819,6 +9179,12 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -8828,7 +9194,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration } - + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8872,8 +9238,14 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8886,7 +9258,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration /** * Get staking context for an address * @summary Get staking context - * @param {GetStakingContextRequest} getStakingContextRequest + * @param {GetStakingContextRequest} getStakingContextRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -8905,8 +9277,14 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -8950,8 +9328,14 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8991,6 +9375,12 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (status !== undefined) { localVarQueryParameter['status'] = status; } @@ -9004,7 +9394,7 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -9027,7 +9417,7 @@ export const StakeApiFp = function(configuration?: Configuration) { /** * Build a new staking operation * @summary Build a new staking operation - * @param {BuildStakingOperationRequest} buildStakingOperationRequest + * @param {BuildStakingOperationRequest} buildStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9059,7 +9449,7 @@ export const StakeApiFp = function(configuration?: Configuration) { /** * Fetch staking rewards for a list of addresses * @summary Fetch staking rewards - * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest + * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest * @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50. * @param {string} [page] A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] Override http request option. @@ -9089,7 +9479,7 @@ export const StakeApiFp = function(configuration?: Configuration) { /** * Get staking context for an address * @summary Get staking context - * @param {GetStakingContextRequest} getStakingContextRequest + * @param {GetStakingContextRequest} getStakingContextRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9144,7 +9534,7 @@ export const StakeApiFactory = function (configuration?: Configuration, basePath /** * Build a new staking operation * @summary Build a new staking operation - * @param {BuildStakingOperationRequest} buildStakingOperationRequest + * @param {BuildStakingOperationRequest} buildStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9170,7 +9560,7 @@ export const StakeApiFactory = function (configuration?: Configuration, basePath /** * Fetch staking rewards for a list of addresses * @summary Fetch staking rewards - * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest + * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest * @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50. * @param {string} [page] A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] Override http request option. @@ -9194,7 +9584,7 @@ export const StakeApiFactory = function (configuration?: Configuration, basePath /** * Get staking context for an address * @summary Get staking context - * @param {GetStakingContextRequest} getStakingContextRequest + * @param {GetStakingContextRequest} getStakingContextRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9239,7 +9629,7 @@ export interface StakeApiInterface { /** * Build a new staking operation * @summary Build a new staking operation - * @param {BuildStakingOperationRequest} buildStakingOperationRequest + * @param {BuildStakingOperationRequest} buildStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StakeApiInterface @@ -9265,7 +9655,7 @@ export interface StakeApiInterface { /** * Fetch staking rewards for a list of addresses * @summary Fetch staking rewards - * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest + * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest * @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50. * @param {string} [page] A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] Override http request option. @@ -9289,7 +9679,7 @@ export interface StakeApiInterface { /** * Get staking context for an address * @summary Get staking context - * @param {GetStakingContextRequest} getStakingContextRequest + * @param {GetStakingContextRequest} getStakingContextRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StakeApiInterface @@ -9334,7 +9724,7 @@ export class StakeApi extends BaseAPI implements StakeApiInterface { /** * Build a new staking operation * @summary Build a new staking operation - * @param {BuildStakingOperationRequest} buildStakingOperationRequest + * @param {BuildStakingOperationRequest} buildStakingOperationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StakeApi @@ -9364,7 +9754,7 @@ export class StakeApi extends BaseAPI implements StakeApiInterface { /** * Fetch staking rewards for a list of addresses * @summary Fetch staking rewards - * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest + * @param {FetchStakingRewardsRequest} fetchStakingRewardsRequest * @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50. * @param {string} [page] A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] Override http request option. @@ -9392,7 +9782,7 @@ export class StakeApi extends BaseAPI implements StakeApiInterface { /** * Get staking context for an address * @summary Get staking context - * @param {GetStakingContextRequest} getStakingContextRequest + * @param {GetStakingContextRequest} getStakingContextRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StakeApi @@ -9446,7 +9836,7 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the trade belongs to * @param {string} tradeId The ID of the trade to broadcast - * @param {BroadcastTradeRequest} broadcastTradeRequest + * @param {BroadcastTradeRequest} broadcastTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9474,8 +9864,11 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -9493,7 +9886,7 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio * @summary Create a new trade for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to conduct the trade from - * @param {CreateTradeRequest} createTradeRequest + * @param {CreateTradeRequest} createTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9518,8 +9911,11 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -9563,8 +9959,14 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -9603,6 +10005,12 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -9612,7 +10020,7 @@ export const TradesApiAxiosParamCreator = function (configuration?: Configuratio } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -9638,7 +10046,7 @@ export const TradesApiFp = function(configuration?: Configuration) { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the trade belongs to * @param {string} tradeId The ID of the trade to broadcast - * @param {BroadcastTradeRequest} broadcastTradeRequest + * @param {BroadcastTradeRequest} broadcastTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9653,7 +10061,7 @@ export const TradesApiFp = function(configuration?: Configuration) { * @summary Create a new trade for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to conduct the trade from - * @param {CreateTradeRequest} createTradeRequest + * @param {CreateTradeRequest} createTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9710,7 +10118,7 @@ export const TradesApiFactory = function (configuration?: Configuration, basePat * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the trade belongs to * @param {string} tradeId The ID of the trade to broadcast - * @param {BroadcastTradeRequest} broadcastTradeRequest + * @param {BroadcastTradeRequest} broadcastTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9722,7 +10130,7 @@ export const TradesApiFactory = function (configuration?: Configuration, basePat * @summary Create a new trade for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to conduct the trade from - * @param {CreateTradeRequest} createTradeRequest + * @param {CreateTradeRequest} createTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -9769,7 +10177,7 @@ export interface TradesApiInterface { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the trade belongs to * @param {string} tradeId The ID of the trade to broadcast - * @param {BroadcastTradeRequest} broadcastTradeRequest + * @param {BroadcastTradeRequest} broadcastTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TradesApiInterface @@ -9781,7 +10189,7 @@ export interface TradesApiInterface { * @summary Create a new trade for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to conduct the trade from - * @param {CreateTradeRequest} createTradeRequest + * @param {CreateTradeRequest} createTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TradesApiInterface @@ -9828,7 +10236,7 @@ export class TradesApi extends BaseAPI implements TradesApiInterface { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the trade belongs to * @param {string} tradeId The ID of the trade to broadcast - * @param {BroadcastTradeRequest} broadcastTradeRequest + * @param {BroadcastTradeRequest} broadcastTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TradesApi @@ -9842,7 +10250,7 @@ export class TradesApi extends BaseAPI implements TradesApiInterface { * @summary Create a new trade for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to conduct the trade from - * @param {CreateTradeRequest} createTradeRequest + * @param {CreateTradeRequest} createTradeRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TradesApi @@ -9918,6 +10326,12 @@ export const TransactionHistoryApiAxiosParamCreator = function (configuration?: const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -9927,7 +10341,7 @@ export const TransactionHistoryApiAxiosParamCreator = function (configuration?: } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10047,7 +10461,7 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the transfer belongs to * @param {string} transferId The ID of the transfer to broadcast - * @param {BroadcastTransferRequest} broadcastTransferRequest + * @param {BroadcastTransferRequest} broadcastTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10075,8 +10489,11 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -10094,7 +10511,7 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura * @summary Create a new transfer for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to transfer from - * @param {CreateTransferRequest} createTransferRequest + * @param {CreateTransferRequest} createTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10119,8 +10536,11 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -10164,8 +10584,14 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10204,6 +10630,12 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -10213,7 +10645,7 @@ export const TransfersApiAxiosParamCreator = function (configuration?: Configura } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10239,7 +10671,7 @@ export const TransfersApiFp = function(configuration?: Configuration) { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the transfer belongs to * @param {string} transferId The ID of the transfer to broadcast - * @param {BroadcastTransferRequest} broadcastTransferRequest + * @param {BroadcastTransferRequest} broadcastTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10254,7 +10686,7 @@ export const TransfersApiFp = function(configuration?: Configuration) { * @summary Create a new transfer for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to transfer from - * @param {CreateTransferRequest} createTransferRequest + * @param {CreateTransferRequest} createTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10311,7 +10743,7 @@ export const TransfersApiFactory = function (configuration?: Configuration, base * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the transfer belongs to * @param {string} transferId The ID of the transfer to broadcast - * @param {BroadcastTransferRequest} broadcastTransferRequest + * @param {BroadcastTransferRequest} broadcastTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10323,7 +10755,7 @@ export const TransfersApiFactory = function (configuration?: Configuration, base * @summary Create a new transfer for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to transfer from - * @param {CreateTransferRequest} createTransferRequest + * @param {CreateTransferRequest} createTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10370,7 +10802,7 @@ export interface TransfersApiInterface { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the transfer belongs to * @param {string} transferId The ID of the transfer to broadcast - * @param {BroadcastTransferRequest} broadcastTransferRequest + * @param {BroadcastTransferRequest} broadcastTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransfersApiInterface @@ -10382,7 +10814,7 @@ export interface TransfersApiInterface { * @summary Create a new transfer for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to transfer from - * @param {CreateTransferRequest} createTransferRequest + * @param {CreateTransferRequest} createTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransfersApiInterface @@ -10429,7 +10861,7 @@ export class TransfersApi extends BaseAPI implements TransfersApiInterface { * @param {string} walletId The ID of the wallet the address belongs to * @param {string} addressId The ID of the address the transfer belongs to * @param {string} transferId The ID of the transfer to broadcast - * @param {BroadcastTransferRequest} broadcastTransferRequest + * @param {BroadcastTransferRequest} broadcastTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransfersApi @@ -10443,7 +10875,7 @@ export class TransfersApi extends BaseAPI implements TransfersApiInterface { * @summary Create a new transfer for an address * @param {string} walletId The ID of the wallet the source address belongs to * @param {string} addressId The ID of the address to transfer from - * @param {CreateTransferRequest} createTransferRequest + * @param {CreateTransferRequest} createTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof TransfersApi @@ -10510,7 +10942,7 @@ export const UsersApiAxiosParamCreator = function (configuration?: Configuration const localVarQueryParameter = {} as any; - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10611,7 +11043,7 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati /** * Create a new wallet scoped to the user. * @summary Create a new wallet - * @param {CreateWalletRequest} [createWalletRequest] + * @param {CreateWalletRequest} [createWalletRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10628,8 +11060,11 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -10665,8 +11100,14 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10703,8 +11144,14 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10737,8 +11184,14 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10769,6 +11222,12 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -10778,7 +11237,7 @@ export const WalletsApiAxiosParamCreator = function (configuration?: Configurati } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10801,7 +11260,7 @@ export const WalletsApiFp = function(configuration?: Configuration) { /** * Create a new wallet scoped to the user. * @summary Create a new wallet - * @param {CreateWalletRequest} [createWalletRequest] + * @param {CreateWalletRequest} [createWalletRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10878,7 +11337,7 @@ export const WalletsApiFactory = function (configuration?: Configuration, basePa /** * Create a new wallet scoped to the user. * @summary Create a new wallet - * @param {CreateWalletRequest} [createWalletRequest] + * @param {CreateWalletRequest} [createWalletRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -10939,7 +11398,7 @@ export interface WalletsApiInterface { /** * Create a new wallet scoped to the user. * @summary Create a new wallet - * @param {CreateWalletRequest} [createWalletRequest] + * @param {CreateWalletRequest} [createWalletRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WalletsApiInterface @@ -11000,7 +11459,7 @@ export class WalletsApi extends BaseAPI implements WalletsApiInterface { /** * Create a new wallet scoped to the user. * @summary Create a new wallet - * @param {CreateWalletRequest} [createWalletRequest] + * @param {CreateWalletRequest} [createWalletRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WalletsApi @@ -11072,7 +11531,7 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat * Create a new webhook scoped to a wallet * @summary Create a new webhook scoped to a wallet * @param {string} walletId The ID of the wallet to create the webhook for. - * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] + * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11092,8 +11551,14 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -11109,7 +11574,7 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat /** * Create a new webhook * @summary Create a new webhook - * @param {CreateWebhookRequest} [createWebhookRequest] + * @param {CreateWebhookRequest} [createWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11126,8 +11591,14 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -11163,8 +11634,14 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -11195,6 +11672,12 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } @@ -11204,7 +11687,7 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat } - + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -11218,7 +11701,7 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat * Update a webhook * @summary Update a webhook * @param {string} webhookId The Webhook id that needs to be updated - * @param {UpdateWebhookRequest} [updateWebhookRequest] + * @param {UpdateWebhookRequest} [updateWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11238,8 +11721,14 @@ export const WebhooksApiAxiosParamCreator = function (configuration?: Configurat const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; + // authentication apiKey required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + + // authentication session required + await setApiKeyToObject(localVarHeaderParameter, "Jwt", configuration) + localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); @@ -11266,7 +11755,7 @@ export const WebhooksApiFp = function(configuration?: Configuration) { * Create a new webhook scoped to a wallet * @summary Create a new webhook scoped to a wallet * @param {string} walletId The ID of the wallet to create the webhook for. - * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] + * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11279,7 +11768,7 @@ export const WebhooksApiFp = function(configuration?: Configuration) { /** * Create a new webhook * @summary Create a new webhook - * @param {CreateWebhookRequest} [createWebhookRequest] + * @param {CreateWebhookRequest} [createWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11320,7 +11809,7 @@ export const WebhooksApiFp = function(configuration?: Configuration) { * Update a webhook * @summary Update a webhook * @param {string} webhookId The Webhook id that needs to be updated - * @param {UpdateWebhookRequest} [updateWebhookRequest] + * @param {UpdateWebhookRequest} [updateWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11344,7 +11833,7 @@ export const WebhooksApiFactory = function (configuration?: Configuration, baseP * Create a new webhook scoped to a wallet * @summary Create a new webhook scoped to a wallet * @param {string} walletId The ID of the wallet to create the webhook for. - * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] + * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11354,7 +11843,7 @@ export const WebhooksApiFactory = function (configuration?: Configuration, baseP /** * Create a new webhook * @summary Create a new webhook - * @param {CreateWebhookRequest} [createWebhookRequest] + * @param {CreateWebhookRequest} [createWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11386,7 +11875,7 @@ export const WebhooksApiFactory = function (configuration?: Configuration, baseP * Update a webhook * @summary Update a webhook * @param {string} webhookId The Webhook id that needs to be updated - * @param {UpdateWebhookRequest} [updateWebhookRequest] + * @param {UpdateWebhookRequest} [updateWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -11406,7 +11895,7 @@ export interface WebhooksApiInterface { * Create a new webhook scoped to a wallet * @summary Create a new webhook scoped to a wallet * @param {string} walletId The ID of the wallet to create the webhook for. - * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] + * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApiInterface @@ -11416,7 +11905,7 @@ export interface WebhooksApiInterface { /** * Create a new webhook * @summary Create a new webhook - * @param {CreateWebhookRequest} [createWebhookRequest] + * @param {CreateWebhookRequest} [createWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApiInterface @@ -11448,7 +11937,7 @@ export interface WebhooksApiInterface { * Update a webhook * @summary Update a webhook * @param {string} webhookId The Webhook id that needs to be updated - * @param {UpdateWebhookRequest} [updateWebhookRequest] + * @param {UpdateWebhookRequest} [updateWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApiInterface @@ -11468,7 +11957,7 @@ export class WebhooksApi extends BaseAPI implements WebhooksApiInterface { * Create a new webhook scoped to a wallet * @summary Create a new webhook scoped to a wallet * @param {string} walletId The ID of the wallet to create the webhook for. - * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] + * @param {CreateWalletWebhookRequest} [createWalletWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApi @@ -11480,7 +11969,7 @@ export class WebhooksApi extends BaseAPI implements WebhooksApiInterface { /** * Create a new webhook * @summary Create a new webhook - * @param {CreateWebhookRequest} [createWebhookRequest] + * @param {CreateWebhookRequest} [createWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApi @@ -11518,7 +12007,7 @@ export class WebhooksApi extends BaseAPI implements WebhooksApiInterface { * Update a webhook * @summary Update a webhook * @param {string} webhookId The Webhook id that needs to be updated - * @param {UpdateWebhookRequest} [updateWebhookRequest] + * @param {UpdateWebhookRequest} [updateWebhookRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof WebhooksApi @@ -11529,3 +12018,4 @@ export class WebhooksApi extends BaseAPI implements WebhooksApiInterface { } + diff --git a/src/coinbase/smart_contract.ts b/src/coinbase/smart_contract.ts index fe124d9d..ee35c0a9 100644 --- a/src/coinbase/smart_contract.ts +++ b/src/coinbase/smart_contract.ts @@ -39,6 +39,15 @@ export class SmartContract { this.model = contractModel; } + /** + * Returns whether the SmartContract is external. + * + * @returns True if the SmartContract is external, false otherwise. + */ + public get isExternal(): boolean { + return this.model.is_external; + } + /** * Returns a list of ContractEvents for the provided network, contract, and event details. * @@ -124,8 +133,10 @@ export class SmartContract { * * @returns The Wallet ID. */ - public getWalletId(): string { - return this.model.wallet_id; + public getWalletId(): string | undefined { + if (!this.model.wallet_id) return undefined; + + return this.model.wallet_id!; } /** @@ -142,8 +153,10 @@ export class SmartContract { * * @returns The Deployer Address. */ - public getDeployerAddress(): string { - return this.model.deployer_address; + public getDeployerAddress(): string | undefined { + if (!this.model.deployer_address) return undefined; + + return this.model.deployer_address!; } /** @@ -159,6 +172,8 @@ export class SmartContract { return SmartContractType.ERC721; case SmartContractTypeModel.Erc1155: return SmartContractType.ERC1155; + case SmartContractTypeModel.Custom: + return SmartContractType.CUSTOM; default: throw new Error(`Unknown smart contract type: ${this.model.type}`); } @@ -170,21 +185,26 @@ export class SmartContract { * @returns The Smart Contract Options. */ public getOptions(): SmartContractOptions { - if (this.isERC20(this.getType(), this.model.options)) { + if (this.isExternal) + throw new Error("SmartContract options cannot be returned for external SmartContract"); + + const options = this.model.options!; + + if (this.isERC20(this.getType(), options)) { return { - name: this.model.options.name, - symbol: this.model.options.symbol, - totalSupply: this.model.options.total_supply, + name: options.name, + symbol: options.symbol, + totalSupply: options.total_supply, } as TokenContractOptions; - } else if (this.isERC721(this.getType(), this.model.options)) { + } else if (this.isERC721(this.getType(), options)) { return { - name: this.model.options.name, - symbol: this.model.options.symbol, - baseURI: this.model.options.base_uri, + name: options.name, + symbol: options.symbol, + baseURI: options.base_uri, } as NFTContractOptions; } else { return { - uri: this.model.options.uri, + uri: options.uri, } as MultiTokenContractOptions; } } @@ -203,8 +223,10 @@ export class SmartContract { * * @returns The Transaction. */ - public getTransaction(): Transaction { - return new Transaction(this.model.transaction); + public getTransaction(): Transaction | undefined { + if (this.isExternal) return undefined; + + return new Transaction(this.model.transaction!); } /** @@ -215,7 +237,9 @@ export class SmartContract { * @returns The hex-encoded signed payload */ async sign(key: ethers.Wallet): Promise { - return this.getTransaction().sign(key); + if (this.isExternal) throw new Error("Cannot sign an external SmartContract"); + + return this.getTransaction()!.sign(key); } /** @@ -225,7 +249,9 @@ export class SmartContract { * @throws {APIError} if the API request to broadcast a SmartContract deployment fails. */ public async broadcast(): Promise { - if (!this.getTransaction().isSigned()) + if (this.isExternal) throw new Error("Cannot broadcast an external SmartContract"); + + if (!this.getTransaction()!.isSigned()) throw new Error("Cannot broadcast unsigned SmartContract deployment"); const deploySmartContractRequest: DeploySmartContractRequest = { @@ -233,8 +259,8 @@ export class SmartContract { }; const response = await Coinbase.apiClients.smartContract!.deploySmartContract( - this.getWalletId(), - this.getDeployerAddress(), + this.getWalletId()!, + this.getDeployerAddress()!, this.getId(), deploySmartContractRequest, ); @@ -255,13 +281,15 @@ export class SmartContract { * @throws {Error} if the SmartContract deployment times out. */ public async wait({ intervalSeconds = 0.2, timeoutSeconds = 10 } = {}): Promise { + if (this.isExternal) throw new Error("Cannot wait for an external SmartContract"); + const startTime = Date.now(); while (Date.now() - startTime < timeoutSeconds * 1000) { await this.reload(); // If the SmartContract deployment is in a terminal state, return the SmartContract. - const status = this.getTransaction().getStatus(); + const status = this.getTransaction()!.getStatus(); if (status === TransactionStatus.COMPLETE || status === TransactionStatus.FAILED) { return this; } @@ -278,9 +306,11 @@ export class SmartContract { * @throws {APIError} if the API request to get a SmartContract fails. */ public async reload(): Promise { + if (this.isExternal) throw new Error("Cannot reload an external SmartContract"); + const result = await Coinbase.apiClients.smartContract!.getSmartContract( - this.getWalletId(), - this.getDeployerAddress(), + this.getWalletId()!, + this.getDeployerAddress()!, this.getId(), ); this.model = result?.data; diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index 90dc36fe..0d903000 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -961,6 +961,7 @@ export enum SmartContractType { ERC20 = "erc20", ERC721 = "erc721", ERC1155 = "erc1155", + CUSTOM = "custom", } /** @@ -1356,18 +1357,15 @@ export type ContractInvocationAPIClient = { export interface SmartContractAPIClient { /** - * List smart contracts belonging to the user for a given wallet and address. + * List smart contracts belonging to the CDP project. * * @summary List smart contracts belonging to the CDP project - * @param walletId - The ID of the wallet the address belongs to. - * @param addressId - The ID of the address to list smart contracts for. + * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Axios request options. * @throws {APIError} If the request fails. */ - listSmartContracts( - walletId: string, - addressId: string, + page?: string, options?: RawAxiosRequestConfig, ): AxiosPromise; diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index 2df83a61..833b29a3 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -16,6 +16,7 @@ import { ERC721_BASE_URI, VALID_SMART_CONTRACT_ERC1155_MODEL, ERC1155_URI, + VALID_SMART_CONTRACT_EXTERNAL_MODEL, } from "./utils"; import { SmartContract } from "../coinbase/smart_contract"; import { ContractEvent } from "../coinbase/contract_event"; @@ -34,6 +35,10 @@ describe("SmartContract", () => { let erc721SmartContract: SmartContract = SmartContract.fromModel(erc721Model); let erc1155Model: SmartContractModel = VALID_SMART_CONTRACT_ERC1155_MODEL; let erc1155SmartContract: SmartContract = SmartContract.fromModel(erc1155Model); + + let externalModel: SmartContractModel = VALID_SMART_CONTRACT_EXTERNAL_MODEL; + let externalSmartContract: SmartContract = SmartContract.fromModel(externalModel); + afterEach(() => { jest.clearAllMocks(); }); @@ -74,12 +79,26 @@ describe("SmartContract", () => { }); }); + describe('#getWalletId', () => { + it("returns the smart contract wallet ID", () => { + expect(erc20SmartContract.getWalletId()).toEqual(VALID_SMART_CONTRACT_ERC20_MODEL.wallet_id); + }); + + it("returns undefined for external contracts", () => { + expect(externalSmartContract.getWalletId()).toBeUndefined(); + }); + }); + describe("#getDeployerAddress", () => { it("returns the smart contract deployer address", () => { expect(erc20SmartContract.getDeployerAddress()).toEqual( VALID_SMART_CONTRACT_ERC20_MODEL.deployer_address, ); }); + + it("returns undefined for external contracts", () => { + expect(externalSmartContract.getDeployerAddress()).toBeUndefined(); + }); }); describe("#getType", () => { @@ -129,15 +148,19 @@ describe("SmartContract", () => { describe("#getTransaction", () => { it("returns the smart contract transaction", () => { expect(erc20SmartContract.getTransaction()).toEqual( - new Transaction(VALID_SMART_CONTRACT_ERC20_MODEL.transaction), + new Transaction(VALID_SMART_CONTRACT_ERC20_MODEL.transaction!), ); }); + + it("returns undefined for external contracts", () => { + expect(externalSmartContract.getTransaction()).toBeUndefined(); + }); }); describe("#sign", () => { let signingKey: any = ethers.Wallet.createRandom(); - it("return the signature", async () => { + it("returns the signature", async () => { const smartContract = SmartContract.fromModel({ ...VALID_SMART_CONTRACT_ERC20_MODEL, transaction: { @@ -150,6 +173,12 @@ describe("SmartContract", () => { expect(signature).toEqual(smartContract.getTransaction()!.getSignature()!); }); + + it("throws an error for external contracts", async () => { + expect(externalSmartContract.sign(signingKey)).rejects.toThrow( + "Cannot sign an external SmartContract", + ); + }); }); describe("#broadcast", () => { @@ -168,7 +197,7 @@ describe("SmartContract", () => { }); }); - describe("when it was successful", () => { + describe("when it is successful", () => { let broadcastedSmartContract: SmartContract; beforeEach(async () => { @@ -186,7 +215,7 @@ describe("SmartContract", () => { it("returns the broadcasted smart contract", async () => { expect(broadcastedSmartContract).toBeInstanceOf(SmartContract); - expect(broadcastedSmartContract.getTransaction().getStatus()).toEqual( + expect(broadcastedSmartContract.getTransaction()!.getStatus()).toEqual( TransactionStatus.BROADCAST, ); }); @@ -236,6 +265,14 @@ describe("SmartContract", () => { expect(erc20SmartContract.broadcast()).rejects.toThrow(APIError); }); }); + + describe("when the contract is external", () => { + it("throws an error", async () => { + expect(externalSmartContract.broadcast()).rejects.toThrow( + "Cannot broadcast an external SmartContract", + ); + }); + }); }); describe("#wait", () => { @@ -253,7 +290,7 @@ describe("SmartContract", () => { it("successfully waits and returns", async () => { const completedSmartContract = await erc20SmartContract.wait(); expect(completedSmartContract).toBeInstanceOf(SmartContract); - expect(completedSmartContract.getTransaction().getStatus()).toEqual( + expect(completedSmartContract.getTransaction()!.getStatus()).toEqual( TransactionStatus.COMPLETE, ); }); @@ -273,7 +310,7 @@ describe("SmartContract", () => { it("successfully waits and returns a failed invocation", async () => { const completedSmartContract = await erc20SmartContract.wait(); expect(completedSmartContract).toBeInstanceOf(SmartContract); - expect(completedSmartContract.getTransaction().getStatus()).toEqual( + expect(completedSmartContract.getTransaction()!.getStatus()).toEqual( TransactionStatus.FAILED, ); }); @@ -296,6 +333,14 @@ describe("SmartContract", () => { ).rejects.toThrow(new TimeoutError("SmartContract deployment timed out")); }); }); + + describe("when the contract is external", () => { + it("throws an error", async () => { + expect(externalSmartContract.wait()).rejects.toThrow( + "Cannot wait for an external SmartContract", + ); + }); + }); }); describe("#reload", () => { @@ -308,9 +353,13 @@ describe("SmartContract", () => { }, }); await erc20SmartContract.reload(); - expect(erc20SmartContract.getTransaction().getStatus()).toEqual(TransactionStatus.COMPLETE); + expect(erc20SmartContract.getTransaction()!.getStatus()).toEqual(TransactionStatus.COMPLETE); expect(Coinbase.apiClients.smartContract!.getSmartContract).toHaveBeenCalledTimes(1); }); + + it("throws an error when the smart contract is external", async () => { + expect(externalSmartContract.reload()).rejects.toThrow("Cannot reload an external SmartContract"); + }); }); describe("#toString", () => { diff --git a/src/tests/utils.ts b/src/tests/utils.ts index 08893a75..3c9ead03 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -302,7 +302,7 @@ export const VALID_SIGNED_CONTRACT_INVOCATION_MODEL: ContractInvocationModel = { }, }; -export const ERC20_NAME = "Test NFT"; +export const ERC20_NAME = "Test ERC20 Token"; export const ERC20_SYMBOL = "TEST"; export const ERC20_TOTAL_SUPPLY = 100; @@ -310,6 +310,8 @@ export const VALID_SMART_CONTRACT_ERC20_MODEL: SmartContractModel = { smart_contract_id: "test-smart-contract-1", network_id: Coinbase.networks.BaseSepolia, wallet_id: walletId, + contract_name: ERC20_NAME, + is_external: false, contract_address: "0xcontract-address", deployer_address: "0xdeployer-address", type: SmartContractType.Erc20, @@ -335,6 +337,8 @@ export const VALID_SMART_CONTRACT_ERC721_MODEL: SmartContractModel = { smart_contract_id: "test-smart-contract-1", network_id: Coinbase.networks.BaseSepolia, wallet_id: walletId, + contract_name: ERC721_NAME, + is_external: false, contract_address: "0xcontract-address", deployer_address: "0xdeployer-address", type: SmartContractType.Erc721, @@ -358,6 +362,8 @@ export const VALID_SMART_CONTRACT_ERC1155_MODEL: SmartContractModel = { smart_contract_id: "test-smart-contract-1", network_id: Coinbase.networks.BaseSepolia, wallet_id: walletId, + contract_name: "", + is_external: false, contract_address: "0xcontract-address", deployer_address: "0xdeployer-address", type: SmartContractType.Erc1155, @@ -374,6 +380,17 @@ export const VALID_SMART_CONTRACT_ERC1155_MODEL: SmartContractModel = { }, }; +export const VALID_SMART_CONTRACT_EXTERNAL_MODEL: SmartContractModel = { + smart_contract_id: "test-smart-contract-external", + network_id: Coinbase.networks.BaseSepolia, + contract_name: ERC20_NAME, + is_external: true, + contract_address: "0xcontract-address", + type: SmartContractType.Custom, + abi: JSON.stringify("some-abi"), +}; + + const asset = Asset.fromModel({ asset_id: Coinbase.assets.Eth, network_id: "base-sepolia", diff --git a/src/tests/wallet_address_test.ts b/src/tests/wallet_address_test.ts index 031ffdf8..35c7982f 100644 --- a/src/tests/wallet_address_test.ts +++ b/src/tests/wallet_address_test.ts @@ -1556,7 +1556,7 @@ describe("WalletAddress", () => { walletAddress = new WalletAddress(addressModel, key as unknown as ethers.Wallet); - const tx = new Transaction(VALID_SMART_CONTRACT_ERC20_MODEL.transaction); + const tx = new Transaction(VALID_SMART_CONTRACT_ERC20_MODEL.transaction!); expectedSignedPayload = await tx.sign(key as unknown as ethers.Wallet); }); @@ -1852,7 +1852,7 @@ describe("WalletAddress", () => { walletAddress = new WalletAddress(addressModel, key as unknown as ethers.Wallet); - const tx = new Transaction(VALID_SMART_CONTRACT_ERC721_MODEL.transaction); + const tx = new Transaction(VALID_SMART_CONTRACT_ERC721_MODEL.transaction!); expectedSignedPayload = await tx.sign(key as unknown as ethers.Wallet); }); @@ -2148,7 +2148,7 @@ describe("WalletAddress", () => { walletAddress = new WalletAddress(addressModel, key as unknown as ethers.Wallet); - const tx = new Transaction(VALID_SMART_CONTRACT_ERC1155_MODEL.transaction); + const tx = new Transaction(VALID_SMART_CONTRACT_ERC1155_MODEL.transaction!); expectedSignedPayload = await tx.sign(key as unknown as ethers.Wallet); }); diff --git a/src/tests/webhook_test.ts b/src/tests/webhook_test.ts index 3e326c8d..448124ce 100644 --- a/src/tests/webhook_test.ts +++ b/src/tests/webhook_test.ts @@ -227,12 +227,13 @@ describe("Webhook", () => { }); it("should update the webhook address list only", async () => { const webhook = Webhook.init(mockModel); - await webhook.update({ eventTypeFilter: { addresses: ["0x1..", "0x2.."] } }); + + await webhook.update({ eventTypeFilter: { wallet_id: "test-wallet-id", addresses: ["0x1..", "0x2.."] } }); expect(Coinbase.apiClients.webhook!.updateWebhook).toHaveBeenCalledWith("test-id", { notification_uri: "https://example.com/callback", event_filters: [{ contract_address: "0x...", from_address: "0x...", to_address: "0x..." }], - event_type_filter: { addresses: ["0x1..", "0x2.."] }, + event_type_filter: { wallet_id: "test-wallet-id", addresses: ["0x1..", "0x2.."] }, }); expect(webhook.getNotificationURI()).toBe("https://example.com/callback"); @@ -245,7 +246,7 @@ describe("Webhook", () => { const webhook = Webhook.init(mockWalletActivityWebhookModel); await webhook.update({ notificationUri: "https://new-url.com/callback", - eventTypeFilter: { addresses: ["0x1..", "0x2.."] }, + eventTypeFilter: { wallet_id: "test-wallet-id", addresses: ["0x1..", "0x2.."] }, }); expect(Coinbase.apiClients.webhook!.updateWebhook).toHaveBeenCalledWith("test-id", { From 58327095b7b3030393dad579db6be98bf00fed1f Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 08:56:25 +0530 Subject: [PATCH 02/25] feat: Add reputation score for an address --- CHANGELOG.md | 3 ++ package.json | 2 +- src/coinbase/address.ts | 27 +++++++++++++ src/coinbase/address_reputation.ts | 60 ++++++++++++++++++++++++++++ src/coinbase/coinbase.ts | 2 + src/coinbase/types.ts | 18 +++++++++ src/tests/address_reputation_test.ts | 52 ++++++++++++++++++++++++ src/tests/address_test.ts | 49 ++++++++++++++++++++++- src/tests/utils.ts | 4 ++ 9 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 src/coinbase/address_reputation.ts create mode 100644 src/tests/address_reputation_test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index da5c3bf3..e4465ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Coinbase Node.js SDK Changelog ## Unreleased +* Add support for fetching address reputation. + +## [0.12.0] - Skipped ### [0.11.3] - 2024-12-10 diff --git a/package.json b/package.json index 9b1630c2..ef339664 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "ISC", "description": "Coinbase Platform SDK", "repository": "https://github.com/coinbase/coinbase-sdk-nodejs", - "version": "0.11.3", + "version": "0.12.0", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index 1f40844a..ae9bbf1b 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -16,6 +16,7 @@ import { formatDate, getWeekBackDate } from "./utils"; import { StakingReward } from "./staking_reward"; import { StakingBalance } from "./staking_balance"; import { Transaction } from "./transaction"; +import { AddressReputation } from "./address_reputation"; /** * A representation of a blockchain address, which is a user-controlled account on a network. @@ -25,6 +26,7 @@ export class Address { protected networkId: string; protected id: string; + protected _reputation?: AddressReputation; /** * Initializes a new Address instance. @@ -295,6 +297,31 @@ export class Address { ); return new FaucetTransaction(response.data); } + /** + * Returns the reputation of the Address. + * + * @returns The reputation of the Address. + * @throws {Error} if the API request to get the Address reputation fails. + * @throws {Error} if the Address reputation is not available. + */ + public async reputation(): Promise { + const response = await Coinbase.apiClients.addressReputation!.getAddressReputation( + this.getNetworkId(), + this.getId(), + ); + + this._reputation = new AddressReputation(response.data); + return this._reputation; + } + + /** + * Returns whether Address's reputation is risky. + * + * @returns {boolean} true if the Address's reputation is risky + */ + public risky(): boolean { + return this._reputation?.risky ?? false; + } /** * Returns a string representation of the address. diff --git a/src/coinbase/address_reputation.ts b/src/coinbase/address_reputation.ts new file mode 100644 index 00000000..d18e9d2c --- /dev/null +++ b/src/coinbase/address_reputation.ts @@ -0,0 +1,60 @@ +import { AddressReputation as AddressReputationModel, AddressReputationMetadata } from "../client"; + +/** + * A representation of the reputation of a blockchain address. + */ +export class AddressReputation { + private model: AddressReputationModel; + /** + * A representation of the reputation of a blockchain address. + * + * @param {AddressReputationModel} model - The reputation model instance. + */ + constructor(model: AddressReputationModel) { + if (!model) { + throw new Error("Address reputation model cannot be empty"); + } + this.model = model; + } + + /** + * Returns the address ID. + * + * @returns {string} The address ID. + */ + public get risky(): boolean { + return this.model.score < 0; + } + + /** + * Returns the score of the address. + * The score is a number between -100 and 100. + * + * @returns {number} The score of the address. + */ + public get score(): number { + return this.model.score; + } + + /** + * Returns the metadata of the address reputation. + * The metadata contains additional information about the address reputation. + * + * @returns {AddressReputationMetadata} The metadata of the address reputation. + */ + public get metadata(): AddressReputationMetadata { + return this.model.metadata; + } + + /** + * Returns the address ID. + * + * @returns {string} The address ID. + */ + toString(): string { + const metadata = Object.entries(this.model.metadata).map(([key, value]) => { + return `${key}: ${value}`; + }); + return `AddressReputation(score: ${this.score}, metadata: {${metadata.join(", ")}})`; + } +} diff --git a/src/coinbase/coinbase.ts b/src/coinbase/coinbase.ts index 56063596..6b9fd818 100644 --- a/src/coinbase/coinbase.ts +++ b/src/coinbase/coinbase.ts @@ -19,6 +19,7 @@ import { TransactionHistoryApiFactory, MPCWalletStakeApiFactory, FundApiFactory, + ReputationApiFactory, } from "../client"; import { BASE_PATH } from "./../client/base"; import { Configuration } from "./../client/configuration"; @@ -172,6 +173,7 @@ export class Coinbase { ); Coinbase.apiKeyPrivateKey = privateKey; Coinbase.useServerSigner = useServerSigner; + Coinbase.apiClients.addressReputation = ReputationApiFactory(config, basePath, axiosInstance); } /** diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index 0d903000..506d2da7 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -61,6 +61,7 @@ import { FundOperationList, CreateFundOperationRequest, CreateFundQuoteRequest, + AddressReputation, } from "./../client/api"; import { Address } from "./address"; import { Wallet } from "./wallet"; @@ -727,6 +728,7 @@ export type ApiClients = { transactionHistory?: TransactionHistoryApiClient; smartContract?: SmartContractAPIClient; fund?: FundOperationApiClient; + addressReputation?: AddressReputationApiClient; }; /** @@ -1503,6 +1505,22 @@ export interface FundOperationApiClient { ): AxiosPromise; } +export interface AddressReputationApiClient { + /** + * Get the reputation of an address + * + * @param networkId - The ID of the blockchain network + * @param addressId - The ID of the address to fetch the reputation for + * @param options - Override http request option. + * @throws {APIError} If the request fails. + */ + getAddressReputation( + networkId: string, + addressId: string, + options?: RawAxiosRequestConfig, + ): AxiosPromise; +} + /** * Options for pagination on list methods. */ diff --git a/src/tests/address_reputation_test.ts b/src/tests/address_reputation_test.ts new file mode 100644 index 00000000..9750916f --- /dev/null +++ b/src/tests/address_reputation_test.ts @@ -0,0 +1,52 @@ +import { AddressReputation } from "../coinbase/address_reputation"; + +describe("AddressReputation", () => { + let addressReputation: AddressReputation; + + beforeEach(() => { + addressReputation = new AddressReputation({ + score: -90, + metadata: { + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }, + }); + }); + + it("returns the score", () => { + expect(addressReputation.score).toBe(-90); + }); + + it("returns the metadata", () => { + expect(addressReputation.metadata).toEqual({ + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }); + }); + + it("returns the risky as true", () => { + expect(addressReputation.risky).toBeTruthy(); + }); + + it("returns the string representation of the address reputation", () => { + expect(addressReputation.toString()).toBe( + "AddressReputation(score: -90, metadata: {unique_days_active: 1, total_transactions: 1, token_swaps_performed: 1, bridge_transactions_performed: 1, smart_contract_deployments: 1, longest_active_streak: 1, lend_borrow_stake_transactions: 1, ens_contract_interactions: 1, current_active_streak: 1, activity_period_days: 1})", + ); + }); +}); diff --git a/src/tests/address_test.ts b/src/tests/address_test.ts index 8b4fc092..82815492 100644 --- a/src/tests/address_test.ts +++ b/src/tests/address_test.ts @@ -1,12 +1,13 @@ import { Coinbase } from "../coinbase/coinbase"; import { Address, TransactionStatus } from "../index"; -import { AddressHistoricalBalanceList, AddressTransactionList } from "../client"; +import { AddressHistoricalBalanceList, AddressTransactionList, AddressReputation } from "../client"; import { VALID_ADDRESS_MODEL, mockReturnValue, newAddressModel, balanceHistoryApiMock, transactionHistoryApiMock, + reputationApiMock, } from "./utils"; import Decimal from "decimal.js"; import { randomUUID } from "crypto"; @@ -269,4 +270,50 @@ describe("Address", () => { expect(paginationResponse.nextPage).toEqual("next page"); }); }); + + describe(".reputation", () => { + beforeEach(() => { + const mockReputationResponse: AddressReputation = { + score: 90, + metadata: { + activity_period_days: 1, + bridge_transactions_performed: 1, + current_active_streak: 1, + ens_contract_interactions: 2, + lend_borrow_stake_transactions: 3, + longest_active_streak: 4, + smart_contract_deployments: 5, + token_swaps_performed: 6, + total_transactions: 7, + unique_days_active: 8, + }, + }; + Coinbase.apiClients.addressReputation = reputationApiMock; + Coinbase.apiClients.addressReputation!.getAddressReputation = + mockReturnValue(mockReputationResponse); + }); + + it("should return address reputation", async () => { + const reputation = await address.reputation(); + expect(reputation.score).toEqual(90); + expect(reputation.metadata).toEqual({ + activity_period_days: 1, + bridge_transactions_performed: 1, + current_active_streak: 1, + ens_contract_interactions: 2, + lend_borrow_stake_transactions: 3, + longest_active_streak: 4, + smart_contract_deployments: 5, + token_swaps_performed: 6, + total_transactions: 7, + unique_days_active: 8, + }); + expect(address.risky).toBe(false); + expect(Coinbase.apiClients.addressReputation!.getAddressReputation).toHaveBeenCalledTimes(1); + expect(Coinbase.apiClients.addressReputation!.getAddressReputation).toHaveBeenCalledWith( + address.getNetworkId(), + address.getId(), + ); + }); + }); }); diff --git a/src/tests/utils.ts b/src/tests/utils.ts index 3c9ead03..0b35a2f5 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -801,6 +801,10 @@ export const fundOperationsApiMock = { createFundQuote: jest.fn(), }; +export const reputationApiMock = { + getAddressReputation: jest.fn(), +}; + export const testAllReadTypesABI = [ { type: "function", From 091f9b3472f36103f2839105a44c4e5c1705be8f Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 21:26:50 +0530 Subject: [PATCH 03/25] feat: Address review comment --- CHANGELOG.md | 5 +++- src/coinbase/address.ts | 12 ++------ src/tests/address_reputation_test.ts | 44 ++++++++++++++++++++++++++-- src/tests/address_test.ts | 3 +- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4465ff0..acf0532b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Coinbase Node.js SDK Changelog ## Unreleased -* Add support for fetching address reputation. + +### [0.13.0] - 2024-12-18 +- Add support for fetching address reputation + - Add `reputation` method to `Address` to fetch the reputation of the address. ## [0.12.0] - Skipped diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index ae9bbf1b..944481b2 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -305,6 +305,9 @@ export class Address { * @throws {Error} if the Address reputation is not available. */ public async reputation(): Promise { + if (this._reputation) { + return this._reputation; + } const response = await Coinbase.apiClients.addressReputation!.getAddressReputation( this.getNetworkId(), this.getId(), @@ -314,15 +317,6 @@ export class Address { return this._reputation; } - /** - * Returns whether Address's reputation is risky. - * - * @returns {boolean} true if the Address's reputation is risky - */ - public risky(): boolean { - return this._reputation?.risky ?? false; - } - /** * Returns a string representation of the address. * diff --git a/src/tests/address_reputation_test.ts b/src/tests/address_reputation_test.ts index 9750916f..6398a829 100644 --- a/src/tests/address_reputation_test.ts +++ b/src/tests/address_reputation_test.ts @@ -1,6 +1,6 @@ import { AddressReputation } from "../coinbase/address_reputation"; -describe("AddressReputation", () => { +describe("AddressReputation for risky address", () => { let addressReputation: AddressReputation; beforeEach(() => { @@ -40,8 +40,8 @@ describe("AddressReputation", () => { }); }); - it("returns the risky as true", () => { - expect(addressReputation.risky).toBeTruthy(); + it("returns the risky as true for score < 0", () => { + expect(addressReputation.risky).toBe(true); }); it("returns the string representation of the address reputation", () => { @@ -49,4 +49,42 @@ describe("AddressReputation", () => { "AddressReputation(score: -90, metadata: {unique_days_active: 1, total_transactions: 1, token_swaps_performed: 1, bridge_transactions_performed: 1, smart_contract_deployments: 1, longest_active_streak: 1, lend_borrow_stake_transactions: 1, ens_contract_interactions: 1, current_active_streak: 1, activity_period_days: 1})", ); }); + + it("should return risky as false for a score > 0", () => { + addressReputation = new AddressReputation({ + score: 90, + metadata: { + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }, + }); + expect(addressReputation.risky).toBe(false); + }); + + it("should return risky as false for a score=0", () => { + addressReputation = new AddressReputation({ + score: 0, + metadata: { + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }, + }); + expect(addressReputation.risky).toBe(false); + }); }); diff --git a/src/tests/address_test.ts b/src/tests/address_test.ts index 82815492..fb02a761 100644 --- a/src/tests/address_test.ts +++ b/src/tests/address_test.ts @@ -271,7 +271,7 @@ describe("Address", () => { }); }); - describe(".reputation", () => { + describe("#reputation", () => { beforeEach(() => { const mockReputationResponse: AddressReputation = { score: 90, @@ -308,7 +308,6 @@ describe("Address", () => { total_transactions: 7, unique_days_active: 8, }); - expect(address.risky).toBe(false); expect(Coinbase.apiClients.addressReputation!.getAddressReputation).toHaveBeenCalledTimes(1); expect(Coinbase.apiClients.addressReputation!.getAddressReputation).toHaveBeenCalledWith( address.getNetworkId(), From 3f1a2bdeb1a385f15b71a336176f162d8edf6200 Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 21:30:26 +0530 Subject: [PATCH 04/25] feat: Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef339664..18826248 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "ISC", "description": "Coinbase Platform SDK", "repository": "https://github.com/coinbase/coinbase-sdk-nodejs", - "version": "0.12.0", + "version": "0.13.0", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { From 36a7e1b1db8013ac5ce3e10be2c12268451732d0 Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 22:10:09 +0530 Subject: [PATCH 05/25] feat: Address review comment --- CHANGELOG.md | 2 -- package.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acf0532b..03e67048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,6 @@ # Coinbase Node.js SDK Changelog ## Unreleased - -### [0.13.0] - 2024-12-18 - Add support for fetching address reputation - Add `reputation` method to `Address` to fetch the reputation of the address. diff --git a/package.json b/package.json index 18826248..9b1630c2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "ISC", "description": "Coinbase Platform SDK", "repository": "https://github.com/coinbase/coinbase-sdk-nodejs", - "version": "0.13.0", + "version": "0.11.3", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { From 3d1a9e002d6d6b817cc9822705f0b02e5fbb2a4e Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 22:18:26 +0530 Subject: [PATCH 06/25] fix: add more test --- src/tests/address_reputation_test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/address_reputation_test.ts b/src/tests/address_reputation_test.ts index 6398a829..723b9d88 100644 --- a/src/tests/address_reputation_test.ts +++ b/src/tests/address_reputation_test.ts @@ -87,4 +87,8 @@ describe("AddressReputation for risky address", () => { }); expect(addressReputation.risky).toBe(false); }); + + it("should throw an error for an empty model", () => { + expect(() => new AddressReputation(null!)).toThrow("Address reputation model cannot be empty"); + }); }); From 41598bf7bef1df636e9b35297c05c6e0779844fa Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 22:53:03 +0530 Subject: [PATCH 07/25] feat: Address review comment --- src/coinbase/address.ts | 2 + src/tests/address_reputation_test.ts | 82 ++++++++++++++-------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index 944481b2..a03fa8fb 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -297,6 +297,7 @@ export class Address { ); return new FaucetTransaction(response.data); } + /** * Returns the reputation of the Address. * @@ -308,6 +309,7 @@ export class Address { if (this._reputation) { return this._reputation; } + const response = await Coinbase.apiClients.addressReputation!.getAddressReputation( this.getNetworkId(), this.getId(), diff --git a/src/tests/address_reputation_test.ts b/src/tests/address_reputation_test.ts index 723b9d88..2328163b 100644 --- a/src/tests/address_reputation_test.ts +++ b/src/tests/address_reputation_test.ts @@ -40,55 +40,57 @@ describe("AddressReputation for risky address", () => { }); }); - it("returns the risky as true for score < 0", () => { - expect(addressReputation.risky).toBe(true); - }); - it("returns the string representation of the address reputation", () => { expect(addressReputation.toString()).toBe( "AddressReputation(score: -90, metadata: {unique_days_active: 1, total_transactions: 1, token_swaps_performed: 1, bridge_transactions_performed: 1, smart_contract_deployments: 1, longest_active_streak: 1, lend_borrow_stake_transactions: 1, ens_contract_interactions: 1, current_active_streak: 1, activity_period_days: 1})", ); }); - it("should return risky as false for a score > 0", () => { - addressReputation = new AddressReputation({ - score: 90, - metadata: { - unique_days_active: 1, - total_transactions: 1, - token_swaps_performed: 1, - bridge_transactions_performed: 1, - smart_contract_deployments: 1, - longest_active_streak: 1, - lend_borrow_stake_transactions: 1, - ens_contract_interactions: 1, - current_active_streak: 1, - activity_period_days: 1, - }, - }); - expect(addressReputation.risky).toBe(false); + it("should throw an error for an empty model", () => { + expect(() => new AddressReputation(null!)).toThrow("Address reputation model cannot be empty"); }); - it("should return risky as false for a score=0", () => { - addressReputation = new AddressReputation({ - score: 0, - metadata: { - unique_days_active: 1, - total_transactions: 1, - token_swaps_performed: 1, - bridge_transactions_performed: 1, - smart_contract_deployments: 1, - longest_active_streak: 1, - lend_borrow_stake_transactions: 1, - ens_contract_interactions: 1, - current_active_streak: 1, - activity_period_days: 1, - }, + describe("#risky", () => { + it("returns the risky as true for score < 0", () => { + expect(addressReputation.risky).toBe(true); }); - expect(addressReputation.risky).toBe(false); - }); - it("should throw an error for an empty model", () => { - expect(() => new AddressReputation(null!)).toThrow("Address reputation model cannot be empty"); + it("should return risky as false for a score > 0", () => { + addressReputation = new AddressReputation({ + score: 90, + metadata: { + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }, + }); + expect(addressReputation.risky).toBe(false); + }); + + it("should return risky as false for a score=0", () => { + addressReputation = new AddressReputation({ + score: 0, + metadata: { + unique_days_active: 1, + total_transactions: 1, + token_swaps_performed: 1, + bridge_transactions_performed: 1, + smart_contract_deployments: 1, + longest_active_streak: 1, + lend_borrow_stake_transactions: 1, + ens_contract_interactions: 1, + current_active_streak: 1, + activity_period_days: 1, + }, + }); + expect(addressReputation.risky).toBe(false); + }); }); }); From 69e76f8867e5e067f1ae45b62eaaf876065faa00 Mon Sep 17 00:00:00 2001 From: arpit-srivastava Date: Tue, 17 Dec 2024 22:57:07 +0530 Subject: [PATCH 08/25] fix: test description --- src/tests/address_reputation_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/address_reputation_test.ts b/src/tests/address_reputation_test.ts index 2328163b..71cac006 100644 --- a/src/tests/address_reputation_test.ts +++ b/src/tests/address_reputation_test.ts @@ -1,6 +1,6 @@ import { AddressReputation } from "../coinbase/address_reputation"; -describe("AddressReputation for risky address", () => { +describe("AddressReputation", () => { let addressReputation: AddressReputation; beforeEach(() => { From b30e18bac610ddbc7a571620ed248bfbde03e162 Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Tue, 17 Dec 2024 13:15:06 -0500 Subject: [PATCH 09/25] Add extra support for more getters for the Validator class --- src/coinbase/validator.ts | 121 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 4 deletions(-) diff --git a/src/coinbase/validator.ts b/src/coinbase/validator.ts index a598f20e..7bd9b148 100644 --- a/src/coinbase/validator.ts +++ b/src/coinbase/validator.ts @@ -1,6 +1,11 @@ import { Coinbase } from "./coinbase"; -import { Validator as ValidatorModel, ValidatorStatus as APIValidatorStatus } from "../client/api"; +import { + Balance, + Validator as ValidatorModel, + ValidatorStatus as APIValidatorStatus, +} from "../client/api"; import { ValidatorStatus } from "./types"; +import { BalanceMap } from "./balance_map"; /** * A representation of a validator onchain. @@ -151,11 +156,119 @@ export class Validator { } } /** - * Returns the string representation of the Validator. + * Returns the network ID. * - * @returns The string representation of the Validator. + * @returns The network ID. + */ + public getNetworkId(): string { + return this.model.network_id; + } + + /** + * Returns the asset ID. + * + * @returns The asset ID. + */ + public getAssetId(): string { + return this.model.asset_id; + } + + /** + * Returns the activation epoch of the validator. + * + * @returns The activation epoch as a string. + */ + public getActivationEpoch(): string { + return this.model.details?.activationEpoch || ""; + } + + /** + * Returns the balance of the validator. + * + * @returns The balance object. + */ + public getBalance(): Balance | undefined { + return this.model.details?.balance; + } + + /** + * Returns the effective balance of the validator. + * + * @returns The effective balance object. + */ + public getEffectiveBalance(): Balance | undefined { + return this.model.details?.effective_balance; + } + + /** + * Returns the exit epoch of the validator. + * + * @returns The exit epoch as a string. + */ + public getExitEpoch(): string { + return this.model.details?.exitEpoch || ""; + } + + /** + * Returns the index of the validator. + * + * @returns The validator index as a string. + */ + public getIndex(): string { + return this.model.details?.index || ""; + } + + /** + * Returns the public key of the validator. + * + * @returns The validator's public key as a string. + */ + public getPublicKey(): string { + return this.model.details?.public_key || ""; + } + + /** + * Returns whether the validator has been slashed. + * + * @returns True if the validator has been slashed, false otherwise. + */ + public isSlashed(): boolean { + return this.model.details?.slashed || false; + } + + /** + * Returns the withdrawable epoch of the validator. + * + * @returns The withdrawable epoch as a string. + */ + public getWithdrawableEpoch(): string { + return this.model.details?.withdrawableEpoch || ""; + } + + /** + * Returns the withdrawal address of the validator. + * + * @returns The withdrawal address as a string. + */ + public getWithdrawalAddress(): string { + return this.model.details?.withdrawal_address || ""; + } + + /** + * Returns the string representation of the Validator including all its details. + * + * @returns The string representation of the Validator including all its details. */ public toString(): string { - return `Id: ${this.getValidatorId()} Status: ${this.getStatus()}`; + return `Validator { Id: ${this.getValidatorId()}, Status: ${this.getStatus()}, Exit Epoch: ${this.getExitEpoch()}, Network ID: ${this.getNetworkId()}, Asset ID: ${this.getAssetId()}, Index: ${this.getIndex()}, Public Key: ${this.getPublicKey()}, Slashed: ${this.isSlashed()}, Withdrawable Epoch: ${this.getWithdrawableEpoch()}, Withdrawal Address: ${this.getWithdrawalAddress()}, Effective Balance: { Amount: ${this.getEffectiveBalance()?.amount}, AssetID: { ${this.getEffectiveBalance()?.asset.asset_id}, Decimals: ${this.getEffectiveBalance()?.asset.decimals}, NetworkID: ${this.getEffectiveBalance()?.asset.network_id} } }, Balance: { Amount ${this.getBalance()?.amount}, Asset: { AssetID: ${this.getBalance()?.asset.asset_id}, Decimals: ${this.getBalance()?.asset.decimals}, NetworkID: ${this.getBalance()?.asset.network_id} } }, Activation Epoch: ${this.getActivationEpoch()} }`; + } + + /** + * Returns the JSON representation of the Validator. + * + * @returns The JSON representation of the Validator. + */ + public toJSON(): string { + return JSON.stringify(this.model); } } From 66e08ccc4086d3cae3e76ebd6d44abfecacec059 Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Tue, 17 Dec 2024 13:40:50 -0500 Subject: [PATCH 10/25] Lint fixes and revert toString method back to original --- src/coinbase/validator.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/coinbase/validator.ts b/src/coinbase/validator.ts index 7bd9b148..32b3bd60 100644 --- a/src/coinbase/validator.ts +++ b/src/coinbase/validator.ts @@ -5,7 +5,6 @@ import { ValidatorStatus as APIValidatorStatus, } from "../client/api"; import { ValidatorStatus } from "./types"; -import { BalanceMap } from "./balance_map"; /** * A representation of a validator onchain. @@ -255,12 +254,12 @@ export class Validator { } /** - * Returns the string representation of the Validator including all its details. + * Returns the string representation of the Validator. * - * @returns The string representation of the Validator including all its details. + * @returns The string representation of the Validator. */ public toString(): string { - return `Validator { Id: ${this.getValidatorId()}, Status: ${this.getStatus()}, Exit Epoch: ${this.getExitEpoch()}, Network ID: ${this.getNetworkId()}, Asset ID: ${this.getAssetId()}, Index: ${this.getIndex()}, Public Key: ${this.getPublicKey()}, Slashed: ${this.isSlashed()}, Withdrawable Epoch: ${this.getWithdrawableEpoch()}, Withdrawal Address: ${this.getWithdrawalAddress()}, Effective Balance: { Amount: ${this.getEffectiveBalance()?.amount}, AssetID: { ${this.getEffectiveBalance()?.asset.asset_id}, Decimals: ${this.getEffectiveBalance()?.asset.decimals}, NetworkID: ${this.getEffectiveBalance()?.asset.network_id} } }, Balance: { Amount ${this.getBalance()?.amount}, Asset: { AssetID: ${this.getBalance()?.asset.asset_id}, Decimals: ${this.getBalance()?.asset.decimals}, NetworkID: ${this.getBalance()?.asset.network_id} } }, Activation Epoch: ${this.getActivationEpoch()} }`; + return `Id: ${this.getValidatorId()} Status: ${this.getStatus()}`; } /** From abc5ac27ade04d846f812a82b60d3f0b018e1a67 Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Tue, 17 Dec 2024 13:57:31 -0500 Subject: [PATCH 11/25] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da5c3bf3..a26fb05a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Add getters for `Validator` object to expose more data to users. + ### [0.11.3] - 2024-12-10 ### Added From 698d8cac8839a46a57e5add3c9c949637a57e1ab Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Tue, 17 Dec 2024 14:20:58 -0500 Subject: [PATCH 12/25] Add validator tests for getters --- src/tests/validator_test.ts | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/tests/validator_test.ts diff --git a/src/tests/validator_test.ts b/src/tests/validator_test.ts new file mode 100644 index 00000000..fcb3c3d6 --- /dev/null +++ b/src/tests/validator_test.ts @@ -0,0 +1,95 @@ +import { Validator } from "../coinbase/validator"; +import { ValidatorStatus } from "../coinbase/types"; +import { Validator as ValidatorModel } from "../client"; +import { Coinbase } from "../coinbase/coinbase"; +import { ValidatorStatus as APIValidatorStatus } from "../client/api"; + +describe("Validator", () => { + let validator: Validator; + + beforeEach(() => { + const mockModel: ValidatorModel = { + validator_id: "123", + status: APIValidatorStatus.Active, + network_id: Coinbase.networks.EthereumHolesky, + asset_id: Coinbase.assets.Eth, + details: { + effective_balance: { + amount: "100", + asset: { network_id: Coinbase.networks.EthereumHolesky, asset_id: Coinbase.assets.Eth }, + }, + balance: { + amount: "200", + asset: { network_id: Coinbase.networks.EthereumHolesky, asset_id: Coinbase.assets.Eth }, + }, + exitEpoch: "epoch-1", + activationEpoch: "epoch-0", + index: "0", + public_key: "public-key-123", + slashed: false, + withdrawableEpoch: "epoch-2", + withdrawal_address: "withdrawal-address-123", + }, + }; + + validator = new Validator(mockModel); + }); + + test("getValidatorId should return the correct validator ID", () => { + expect(validator.getValidatorId()).toBe("123"); + }); + + test("getStatus should return the correct status", () => { + expect(validator.getStatus()).toBe(ValidatorStatus.ACTIVE); + }); + + test("getNetworkId should return the correct network ID", () => { + expect(validator.getNetworkId()).toBe(Coinbase.networks.EthereumHolesky); + }); + + test("getAssetId should return the correct asset ID", () => { + expect(validator.getAssetId()).toBe(Coinbase.assets.Eth); + }); + + test("getActivationEpoch should return the correct activation epoch", () => { + expect(validator.getActivationEpoch()).toBe("epoch-0"); + }); + + test("getExitEpoch should return the correct exit epoch", () => { + expect(validator.getExitEpoch()).toBe("epoch-1"); + }); + + test("getIndex should return the correct index", () => { + expect(validator.getIndex()).toBe("0"); + }); + + test("getPublicKey should return the correct public key", () => { + expect(validator.getPublicKey()).toBe("public-key-123"); + }); + + test("isSlashed should return the correct slashed status", () => { + expect(validator.isSlashed()).toBe(false); + }); + + test("getWithdrawableEpoch should return the correct withdrawable epoch", () => { + expect(validator.getWithdrawableEpoch()).toBe("epoch-2"); + }); + + test("getWithdrawalAddress should return the correct withdrawal address", () => { + expect(validator.getWithdrawalAddress()).toBe("withdrawal-address-123"); + }); + + test("getEffectiveBalance should return the correct effective balance", () => { + expect(validator.getEffectiveBalance()).toEqual({ + amount: "100", + asset: { network_id: Coinbase.networks.EthereumHolesky, asset_id: Coinbase.assets.Eth }, + }); + }); + + test("getBalance should return the correct balance", () => { + expect(validator.getBalance()).toEqual({ + amount: "200", + asset: { network_id: Coinbase.networks.EthereumHolesky, asset_id: Coinbase.assets.Eth }, + }); + }); +}); From 63032fadf91f253e585f4455c444bdb3af41d5c4 Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Tue, 17 Dec 2024 14:22:59 -0500 Subject: [PATCH 13/25] Update CHANGELOG with validator test file line item --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a26fb05a..87151bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Add getters for `Validator` object to expose more data to users. +- Add test file for `Validator` object. ### [0.11.3] - 2024-12-10 From ffa8518d81c1342afac51c6a454df57557294be4 Mon Sep 17 00:00:00 2001 From: Ryan Gilbert Date: Tue, 17 Dec 2024 11:08:43 -0500 Subject: [PATCH 14/25] chore: add networkId to WalletData --- CHANGELOG.md | 1 + src/coinbase/types.ts | 2 ++ src/coinbase/wallet.ts | 3 ++- src/tests/e2e.ts | 7 ++++++- src/tests/wallet_test.ts | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e3b7b9..b73bb193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Add support for fetching address reputation - Add `reputation` method to `Address` to fetch the reputation of the address. +- Add `networkId` to `WalletData` so that it is saved with the seed data and surfaced via the export function ## [0.12.0] - Skipped diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index 506d2da7..b07a790b 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -818,6 +818,7 @@ export enum FundOperationStatus { export type WalletData = { walletId: string; seed: string; + networkId: string; }; /** @@ -828,6 +829,7 @@ export type SeedData = { encrypted: boolean; authTag: string; iv: string; + networkId: string; }; /** diff --git a/src/coinbase/wallet.ts b/src/coinbase/wallet.ts index b8b16e97..7151c28c 100644 --- a/src/coinbase/wallet.ts +++ b/src/coinbase/wallet.ts @@ -221,7 +221,7 @@ export class Wallet { if (!this.seed) { throw new Error("Cannot export Wallet without loaded seed"); } - return { walletId: this.getId()!, seed: this.seed }; + return { walletId: this.getId()!, seed: this.seed, networkId: this.getNetworkId() }; } /** @@ -631,6 +631,7 @@ export class Wallet { encrypted: encrypt, authTag: authTag, iv: iv, + networkId: data.networkId, }; fs.writeFileSync(filePath, JSON.stringify(existingSeedsInStore, null, 2), "utf8"); diff --git a/src/tests/e2e.ts b/src/tests/e2e.ts index 6fc2fce1..dba5626d 100644 --- a/src/tests/e2e.ts +++ b/src/tests/e2e.ts @@ -54,7 +54,11 @@ describe("Coinbase SDK E2E Test", () => { const walletId = Object.keys(seedFile)[0]; const seed = seedFile[walletId].seed; - const importedWallet = await Wallet.import({ seed, walletId }); + const importedWallet = await Wallet.import({ + seed, + walletId, + networkId: Coinbase.networks.BaseSepolia, + }); expect(importedWallet).toBeDefined(); expect(importedWallet.getId()).toBe(walletId); console.log( @@ -138,6 +142,7 @@ describe("Coinbase SDK E2E Test", () => { encrypted: false, authTag: "", iv: "", + networkId: exportedWallet.networkId, }); }, 60000); }); diff --git a/src/tests/wallet_test.ts b/src/tests/wallet_test.ts index ba37aef3..c1e63468 100644 --- a/src/tests/wallet_test.ts +++ b/src/tests/wallet_test.ts @@ -1197,6 +1197,7 @@ describe("Wallet Class", () => { expect(walletSeedData[walletId].iv).toBe(""); expect(walletSeedData[walletId].authTag).toBe(""); expect(walletSeedData[walletId].seed).toBe(seed); + expect(walletSeedData[walletId].networkId).toBe(seedWallet.getNetworkId()); }); it("should save the seed when encryption is true", async () => { From dbd33ff3f85f0119da6d9e7978c608a06387df28 Mon Sep 17 00:00:00 2001 From: Ryan Gilbert Date: Wed, 18 Dec 2024 16:41:39 -0500 Subject: [PATCH 15/25] chore: make network_id in WalletData optional (#348) --- src/coinbase/types.ts | 2 +- src/coinbase/wallet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index b07a790b..110e4faf 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -818,7 +818,7 @@ export enum FundOperationStatus { export type WalletData = { walletId: string; seed: string; - networkId: string; + networkId?: string; }; /** diff --git a/src/coinbase/wallet.ts b/src/coinbase/wallet.ts index 7151c28c..c44f0dde 100644 --- a/src/coinbase/wallet.ts +++ b/src/coinbase/wallet.ts @@ -217,7 +217,7 @@ export class Wallet { * @returns The Wallet's data. * @throws {APIError} - If the request fails. */ - public export(): WalletData { + public export(): Required { if (!this.seed) { throw new Error("Cannot export Wallet without loaded seed"); } From 31e5ef822f9cee5aa514e2dc9338e66ece0d4ac8 Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 13:29:44 -0800 Subject: [PATCH 16/25] Support register/update/list Smart Contract --- CHANGELOG.md | 2 + src/client/api.ts | 2 +- src/coinbase/smart_contract.ts | 91 ++++++++++++++++++++++++ src/coinbase/types.ts | 38 ++++++++++ src/tests/smart_contract_test.ts | 118 ++++++++++++++++++++++++++++++- src/tests/utils.ts | 2 + 6 files changed, 251 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73bb193..4449f383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Coinbase Node.js SDK Changelog ## Unreleased +- Add support for registering, updating, and listing smart contracts that are + deployed external to CDP. - Add support for fetching address reputation - Add `reputation` method to `Address` to fetch the reputation of the address. - Add `networkId` to `WalletData` so that it is saved with the seed data and surfaced via the export function diff --git a/src/client/api.ts b/src/client/api.ts index 39ca17cf..a3748041 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -8596,7 +8596,7 @@ export const SmartContractsApiAxiosParamCreator = function (configuration?: Conf baseOptions = configuration.baseOptions; } - const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; diff --git a/src/coinbase/smart_contract.ts b/src/coinbase/smart_contract.ts index ee35c0a9..4b2969c6 100644 --- a/src/coinbase/smart_contract.ts +++ b/src/coinbase/smart_contract.ts @@ -15,6 +15,8 @@ import { TokenContractOptions, MultiTokenContractOptions, TransactionStatus, + PaginationOptions, + PaginationResponse, } from "./types"; import { Coinbase } from "./coinbase"; import { delay } from "./utils"; @@ -100,6 +102,67 @@ export class SmartContract { return contractEvents; } + /** + * Register a smart contract. + * + * @param networkId - The network ID. + * @param contractAddress - The contract address. + * @param abi - The ABI of the contract. + * @param contractName - The contract name. + * @returns The smart contract. + */ + public static async register( + networkId: string, + contractAddress: string, + abi: object, + contractName?: string, + ): Promise { + const response = await Coinbase.apiClients.smartContract!.registerSmartContract( + networkId, + contractAddress, + { + abi: JSON.stringify(abi), + contract_name: contractName, + }, + ); + return SmartContract.fromModel(response.data); + } + + /** + * Lists Smart Contracts. + * + * @param options - The pagination options. + * @param options.page - The cursor for pagination across multiple pages of Smart Contract. Don\'t include this parameter on the first call. Use the next page value returned in a previous response to request subsequent results. + * + * @returns The paginated list response of Smart Contracts. + */ + public static async list({ page = undefined }: PaginationOptions = {}): Promise< + PaginationResponse + > { + const data: SmartContract[] = []; + let nextPage: string | undefined; + + const response = await Coinbase.apiClients.smartContract!.listSmartContracts(page); + const smartContracts = response.data.data; + for (const sc of smartContracts) { + data.push(new SmartContract(sc)); + } + + const hasMore: boolean = response.data.has_more ? response.data.has_more : false; + + if (hasMore) { + if (response.data.next_page) { + nextPage = response.data.next_page; + } + } + + return { + data, + hasMore, + nextPage, + }; + } + /** * Converts a SmartContractModel into a SmartContract object. * @@ -139,6 +202,15 @@ export class SmartContract { return this.model.wallet_id!; } + /** + * Returns the name of the smart contract. + * + * @returns The contract name. + */ + public getContractName(): string { + return this.model.contract_name; + } + /** * Returns the Contract Address of the smart contract. * @@ -242,6 +314,25 @@ export class SmartContract { return this.getTransaction()!.sign(key); } + /** + * Update a smart contract. + * + * @param abi - The new ABI of the contract. + * @param contractName - The new contract name. + * @returns The smart contract. + */ + public async update(abi?: object, contractName?: string): Promise { + const response = await Coinbase.apiClients.smartContract!.updateSmartContract( + this.getNetworkId(), + this.getContractAddress(), + { + abi: JSON.stringify(abi), + contract_name: contractName, + }, + ); + return SmartContract.fromModel(response.data); + } + /** * Broadcasts the SmartContract deployment to the Network. * diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index b07a790b..7398c418 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -62,6 +62,8 @@ import { CreateFundOperationRequest, CreateFundQuoteRequest, AddressReputation, + RegisterSmartContractRequest, + UpdateSmartContractRequest, } from "./../client/api"; import { Address } from "./address"; import { Wallet } from "./wallet"; @@ -1437,6 +1439,42 @@ export interface SmartContractAPIClient { contractAddress: string, readContractRequest: ReadContractRequest, ): AxiosPromise; + + /** + * Register a smart contract. + * + * @summary Register a smart contract. + * @param {string} [networkId] - The network ID. + * @param {string} [contractAddress] - The contract address. + * @param {RegisterSmartContractRequest} [registerSmartContractRequest] - The request body containing the register smart contract details. + * @param options - Axios request options + * @returns - A promise resolving to the register smart contract result + * @throws {APIError} If the request fails + */ + registerSmartContract( + networkId: string, + contractAddress: string, + registerSmartContractRequest: RegisterSmartContractRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise; + + /** + * Update a smart contract. + * + * @summary Update a smart contract. + * @param {string} [networkId] - The network ID. + * @param {string} [contractAddress] - The contract address. + * @param {UpdateSmartContractRequest} [updateSmartContractRequest] - The request body containing the update smart contract details. + * @param options - Axios request options + * @returns - A promise resolving to the update smart contract result + * @throws {APIError} If the request fails + */ + updateSmartContract( + networkId: string, + contractAddress: string, + updateSmartContractRequest: UpdateSmartContractRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise; } export interface FundOperationApiClient { diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index 833b29a3..39360d6f 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -17,6 +17,7 @@ import { VALID_SMART_CONTRACT_ERC1155_MODEL, ERC1155_URI, VALID_SMART_CONTRACT_EXTERNAL_MODEL, + testAllReadTypesABI, } from "./utils"; import { SmartContract } from "../coinbase/smart_contract"; import { ContractEvent } from "../coinbase/contract_event"; @@ -55,6 +56,121 @@ describe("SmartContract", () => { }); }); + describe("SmartContract.register", () => { + const networkId = erc20Model.network_id; + const contractName = erc20Model.contract_name; + const contractAddress = erc20Model.contract_address; + + it("should register a new smart contract", async () => { + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.registerSmartContract = jest + .fn() + .mockResolvedValue({ data: erc20Model }); + + const smartContract = await SmartContract.register( + networkId, + contractAddress, + testAllReadTypesABI, + contractName, + ); + + expect(Coinbase.apiClients.smartContract!.registerSmartContract).toHaveBeenCalledWith( + networkId, + contractAddress, + { + abi: JSON.stringify(testAllReadTypesABI), + contract_name: contractName, + }, + ); + expect(smartContract).toBeInstanceOf(SmartContract); + expect(smartContract.getContractAddress()).toBe(contractAddress); + }); + + it("should throw an error if creation fails", async () => { + Coinbase.apiClients.smartContract!.registerSmartContract = jest + .fn() + .mockRejectedValue(new Error("Failed to register the smart contract")); + await expect( + SmartContract.register(networkId, contractAddress, testAllReadTypesABI, contractName), + ).rejects.toThrow("Failed to register the smart contract"); + }); + }); + + describe("SmartContract.update", () => { + const networkId = erc20Model.network_id; + const contractAddress = erc20Model.contract_address; + + const updatedContract = JSON.parse(JSON.stringify(erc20Model)); + const updatedAbiJson = { abi: "data2" }; + updatedContract.contract_name = "UpdatedContractName"; + updatedContract.abi = JSON.stringify(updatedAbiJson); + + it("should update an existing smart contract", async () => { + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.updateSmartContract = jest + .fn() + .mockResolvedValue({ data: updatedContract }); + + const smartContract = await erc20SmartContract.update( + updatedAbiJson, + updatedContract.contract_name, + ); + + expect(Coinbase.apiClients.smartContract!.updateSmartContract).toHaveBeenCalledWith( + networkId, + contractAddress, + { + abi: updatedContract.abi, + contract_name: updatedContract.contract_name, + }, + ); + expect(smartContract).toBeInstanceOf(SmartContract); + expect(smartContract.getContractAddress()).toBe(contractAddress); + expect(smartContract.getAbi()).toEqual(updatedAbiJson); + expect(smartContract.getContractName()).toEqual(updatedContract.contract_name); + }); + + it("should throw an error if creation fails", async () => { + Coinbase.apiClients.smartContract!.updateSmartContract = jest + .fn() + .mockRejectedValue(new Error("Failed to update the smart contract")); + await expect( + erc20SmartContract.update( + testAllReadTypesABI, + updatedContract.contract_name, + ), + ).rejects.toThrow("Failed to update the smart contract"); + }); + }); + + describe(".list", () => { + it("should list smart contracts", async () => { + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.listSmartContracts = jest.fn().mockResolvedValue({ + data: { + data: [erc20Model], + has_more: true, + next_page: null, + }, + }); + const paginationResponse = await SmartContract.list(); + const smartContracts = paginationResponse.data; + + expect(Coinbase.apiClients.smartContract!.listSmartContracts).toHaveBeenCalledWith(undefined); + expect(smartContracts.length).toBe(1); + expect(smartContracts[0].getContractAddress()).toBe(erc20Model.contract_address); + expect(paginationResponse.hasMore).toBe(true); + expect(paginationResponse.nextPage).toBe(undefined); + }); + + it("should throw an error if list fails", async () => { + Coinbase.apiClients.smartContract!.listSmartContracts = mockReturnRejectedValue( + new APIError(""), + ); + await expect(SmartContract.list()).rejects.toThrow(APIError); + }); + }); + describe("#getId", () => { it("returns the smart contract ID", () => { expect(erc20SmartContract.getId()).toEqual( @@ -333,7 +449,7 @@ describe("SmartContract", () => { ).rejects.toThrow(new TimeoutError("SmartContract deployment timed out")); }); }); - + describe("when the contract is external", () => { it("throws an error", async () => { expect(externalSmartContract.wait()).rejects.toThrow( diff --git a/src/tests/utils.ts b/src/tests/utils.ts index 0b35a2f5..168077a3 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -781,6 +781,8 @@ export const smartContractApiMock = { getSmartContract: jest.fn(), listSmartContracts: jest.fn(), readContract: jest.fn(), + registerSmartContract: jest.fn(), + updateSmartContract: jest.fn(), }; export const contractInvocationApiMock = { From c5e60de5f585109b08946c4dc9077a5915c2f58a Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 14:44:27 -0800 Subject: [PATCH 17/25] address comment --- src/tests/smart_contract_test.ts | 33 ++++++++++++++++---------------- src/tests/utils.ts | 9 +++++++++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index 39360d6f..c84dcc67 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -17,7 +17,7 @@ import { VALID_SMART_CONTRACT_ERC1155_MODEL, ERC1155_URI, VALID_SMART_CONTRACT_EXTERNAL_MODEL, - testAllReadTypesABI, + testAllReadTypesABI, VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL, } from "./utils"; import { SmartContract } from "../coinbase/smart_contract"; import { ContractEvent } from "../coinbase/contract_event"; @@ -31,8 +31,10 @@ import { TimeoutError } from "../coinbase/errors"; describe("SmartContract", () => { let erc20Model: SmartContractModel = VALID_SMART_CONTRACT_ERC20_MODEL; + let erc20ExternalModel: SmartContractModel = VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL; let erc721Model: SmartContractModel = VALID_SMART_CONTRACT_ERC721_MODEL; let erc20SmartContract: SmartContract = SmartContract.fromModel(erc20Model); + let erc20ExternalSmartContract: SmartContract = SmartContract.fromModel(erc20ExternalModel); let erc721SmartContract: SmartContract = SmartContract.fromModel(erc721Model); let erc1155Model: SmartContractModel = VALID_SMART_CONTRACT_ERC1155_MODEL; let erc1155SmartContract: SmartContract = SmartContract.fromModel(erc1155Model); @@ -56,16 +58,16 @@ describe("SmartContract", () => { }); }); - describe("SmartContract.register", () => { - const networkId = erc20Model.network_id; - const contractName = erc20Model.contract_name; - const contractAddress = erc20Model.contract_address; + describe(".register", () => { + const networkId = erc20ExternalModel.network_id; + const contractName = erc20ExternalModel.contract_name; + const contractAddress = erc20ExternalModel.contract_address; it("should register a new smart contract", async () => { Coinbase.apiClients.smartContract = smartContractApiMock; Coinbase.apiClients.smartContract.registerSmartContract = jest .fn() - .mockResolvedValue({ data: erc20Model }); + .mockResolvedValue({ data: erc20ExternalModel }); const smartContract = await SmartContract.register( networkId, @@ -96,11 +98,11 @@ describe("SmartContract", () => { }); }); - describe("SmartContract.update", () => { - const networkId = erc20Model.network_id; - const contractAddress = erc20Model.contract_address; + describe(".update", () => { + const networkId = erc20ExternalModel.network_id; + const contractAddress = erc20ExternalModel.contract_address; - const updatedContract = JSON.parse(JSON.stringify(erc20Model)); + const updatedContract = JSON.parse(JSON.stringify(erc20ExternalModel)); const updatedAbiJson = { abi: "data2" }; updatedContract.contract_name = "UpdatedContractName"; updatedContract.abi = JSON.stringify(updatedAbiJson); @@ -111,7 +113,7 @@ describe("SmartContract", () => { .fn() .mockResolvedValue({ data: updatedContract }); - const smartContract = await erc20SmartContract.update( + const smartContract = await erc20ExternalSmartContract.update( updatedAbiJson, updatedContract.contract_name, ); @@ -135,10 +137,7 @@ describe("SmartContract", () => { .fn() .mockRejectedValue(new Error("Failed to update the smart contract")); await expect( - erc20SmartContract.update( - testAllReadTypesABI, - updatedContract.contract_name, - ), + erc20ExternalSmartContract.update(testAllReadTypesABI, updatedContract.contract_name), ).rejects.toThrow("Failed to update the smart contract"); }); }); @@ -148,7 +147,7 @@ describe("SmartContract", () => { Coinbase.apiClients.smartContract = smartContractApiMock; Coinbase.apiClients.smartContract.listSmartContracts = jest.fn().mockResolvedValue({ data: { - data: [erc20Model], + data: [erc20ExternalModel], has_more: true, next_page: null, }, @@ -158,7 +157,7 @@ describe("SmartContract", () => { expect(Coinbase.apiClients.smartContract!.listSmartContracts).toHaveBeenCalledWith(undefined); expect(smartContracts.length).toBe(1); - expect(smartContracts[0].getContractAddress()).toBe(erc20Model.contract_address); + expect(smartContracts[0].getContractAddress()).toBe(erc20ExternalModel.contract_address); expect(paginationResponse.hasMore).toBe(true); expect(paginationResponse.nextPage).toBe(undefined); }); diff --git a/src/tests/utils.ts b/src/tests/utils.ts index 168077a3..373fb829 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -330,6 +330,15 @@ export const VALID_SMART_CONTRACT_ERC20_MODEL: SmartContractModel = { }, }; +export const VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL: SmartContractModel = { + network_id: Coinbase.networks.BaseSepolia, + contract_name: ERC20_NAME, + is_external: true, + contract_address: "0xcontract-address", + type: SmartContractType.Custom, + abi: JSON.stringify("some-abi"), +}; + export const ERC721_NAME = "Test NFT"; export const ERC721_SYMBOL = "TEST"; export const ERC721_BASE_URI = "https://example.com/metadata/"; From 292d4e6551550c96560d37a9c5ccd8227b144990 Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 14:46:25 -0800 Subject: [PATCH 18/25] address --- src/tests/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/utils.ts b/src/tests/utils.ts index 373fb829..cd0c9c9d 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -331,6 +331,7 @@ export const VALID_SMART_CONTRACT_ERC20_MODEL: SmartContractModel = { }; export const VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL: SmartContractModel = { + smart_contract_id: "test-smart-contract-1", network_id: Coinbase.networks.BaseSepolia, contract_name: ERC20_NAME, is_external: true, From e0dedc5c0cef6914c7b538f73d8f37c8fc1d8908 Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 14:53:13 -0800 Subject: [PATCH 19/25] fix lint --- src/tests/smart_contract_test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index c84dcc67..c5e3c4c6 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -17,7 +17,8 @@ import { VALID_SMART_CONTRACT_ERC1155_MODEL, ERC1155_URI, VALID_SMART_CONTRACT_EXTERNAL_MODEL, - testAllReadTypesABI, VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL, + testAllReadTypesABI, + VALID_EXTERNAL_SMART_CONTRACT_ERC20_MODEL, } from "./utils"; import { SmartContract } from "../coinbase/smart_contract"; import { ContractEvent } from "../coinbase/contract_event"; From f27028d7c0fdc109839cb9743ceddc7b39555dad Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 14:56:13 -0800 Subject: [PATCH 20/25] update --- src/tests/smart_contract_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index c5e3c4c6..d3a7e9dc 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -59,7 +59,7 @@ describe("SmartContract", () => { }); }); - describe(".register", () => { + describe("SmartContract.register", () => { const networkId = erc20ExternalModel.network_id; const contractName = erc20ExternalModel.contract_name; const contractAddress = erc20ExternalModel.contract_address; @@ -99,7 +99,7 @@ describe("SmartContract", () => { }); }); - describe(".update", () => { + describe("SmartContract.update", () => { const networkId = erc20ExternalModel.network_id; const contractAddress = erc20ExternalModel.contract_address; From 4246f4a6b285b6d7fbc7a6b511ecb069ad75dfb0 Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 15:23:47 -0800 Subject: [PATCH 21/25] fix typo --- src/tests/smart_contract_test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index d3a7e9dc..fbaeb3f9 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -59,7 +59,7 @@ describe("SmartContract", () => { }); }); - describe("SmartContract.register", () => { + describe(".register", () => { const networkId = erc20ExternalModel.network_id; const contractName = erc20ExternalModel.contract_name; const contractAddress = erc20ExternalModel.contract_address; @@ -89,7 +89,7 @@ describe("SmartContract", () => { expect(smartContract.getContractAddress()).toBe(contractAddress); }); - it("should throw an error if creation fails", async () => { + it("should throw an error if register fails", async () => { Coinbase.apiClients.smartContract!.registerSmartContract = jest .fn() .mockRejectedValue(new Error("Failed to register the smart contract")); @@ -99,7 +99,7 @@ describe("SmartContract", () => { }); }); - describe("SmartContract.update", () => { + describe(".update", () => { const networkId = erc20ExternalModel.network_id; const contractAddress = erc20ExternalModel.contract_address; @@ -133,7 +133,7 @@ describe("SmartContract", () => { expect(smartContract.getContractName()).toEqual(updatedContract.contract_name); }); - it("should throw an error if creation fails", async () => { + it("should throw an error if update fails", async () => { Coinbase.apiClients.smartContract!.updateSmartContract = jest .fn() .mockRejectedValue(new Error("Failed to update the smart contract")); From 56f7a6d52b1f5630a413cb2375a0b9a78225d20a Mon Sep 17 00:00:00 2001 From: Jianlun Zhong Date: Wed, 18 Dec 2024 17:43:18 -0800 Subject: [PATCH 22/25] feat: Modify Smart Contract API input and add more tests --- src/coinbase/smart_contract.ts | 30 ++++---- src/coinbase/types.ts | 18 +++++ src/tests/smart_contract_test.ts | 124 +++++++++++++++++++++++++------ 3 files changed, 138 insertions(+), 34 deletions(-) diff --git a/src/coinbase/smart_contract.ts b/src/coinbase/smart_contract.ts index 4b2969c6..0f439a15 100644 --- a/src/coinbase/smart_contract.ts +++ b/src/coinbase/smart_contract.ts @@ -14,9 +14,11 @@ import { NFTContractOptions, TokenContractOptions, MultiTokenContractOptions, + RegisterContractOptions, TransactionStatus, PaginationOptions, PaginationResponse, + UpdateContractOptions, } from "./types"; import { Coinbase } from "./coinbase"; import { delay } from "./utils"; @@ -105,18 +107,19 @@ export class SmartContract { /** * Register a smart contract. * - * @param networkId - The network ID. - * @param contractAddress - The contract address. - * @param abi - The ABI of the contract. - * @param contractName - The contract name. + * @param options - The options to register a smart contract. + * @param options.networkId - The network ID. + * @param options.contractAddress - The contract address. + * @param options.abi - The ABI of the contract. + * @param options.contractName - The contract name. * @returns The smart contract. */ - public static async register( - networkId: string, - contractAddress: string, - abi: object, - contractName?: string, - ): Promise { + public static async register({ + networkId, + contractAddress, + abi, + contractName, + }: RegisterContractOptions): Promise { const response = await Coinbase.apiClients.smartContract!.registerSmartContract( networkId, contractAddress, @@ -317,11 +320,12 @@ export class SmartContract { /** * Update a smart contract. * - * @param abi - The new ABI of the contract. - * @param contractName - The new contract name. + * @param options - The options to update a smart contract. + * @param options.abi - The new ABI of the contract. + * @param options.contractName - The new contract name. * @returns The smart contract. */ - public async update(abi?: object, contractName?: string): Promise { + public async update({ abi, contractName }: UpdateContractOptions): Promise { const response = await Coinbase.apiClients.smartContract!.updateSmartContract( this.getNetworkId(), this.getContractAddress(), diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index 02381ac5..49f6457f 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -1284,6 +1284,24 @@ export type UpdateWebhookOptions = { eventTypeFilter?: WebhookEventTypeFilter; }; +/** + * Options for registering a smart contract. + */ +export type RegisterContractOptions = { + networkId: string; + contractAddress: string; + abi: object; + contractName?: string; +}; + +/** + * Options for updating a smart contract. + */ +export type UpdateContractOptions = { + abi?: object; + contractName?: string; +}; + /** * ContractInvocationAPI client type definition. */ diff --git a/src/tests/smart_contract_test.ts b/src/tests/smart_contract_test.ts index fbaeb3f9..e396a5bb 100644 --- a/src/tests/smart_contract_test.ts +++ b/src/tests/smart_contract_test.ts @@ -70,12 +70,12 @@ describe("SmartContract", () => { .fn() .mockResolvedValue({ data: erc20ExternalModel }); - const smartContract = await SmartContract.register( - networkId, - contractAddress, - testAllReadTypesABI, - contractName, - ); + const smartContract = await SmartContract.register({ + networkId: networkId, + contractAddress: contractAddress, + abi: testAllReadTypesABI, + contractName: contractName, + }); expect(Coinbase.apiClients.smartContract!.registerSmartContract).toHaveBeenCalledWith( networkId, @@ -94,7 +94,12 @@ describe("SmartContract", () => { .fn() .mockRejectedValue(new Error("Failed to register the smart contract")); await expect( - SmartContract.register(networkId, contractAddress, testAllReadTypesABI, contractName), + SmartContract.register({ + networkId: networkId, + contractAddress: contractAddress, + abi: testAllReadTypesABI, + contractName: contractName, + }), ).rejects.toThrow("Failed to register the smart contract"); }); }); @@ -103,21 +108,21 @@ describe("SmartContract", () => { const networkId = erc20ExternalModel.network_id; const contractAddress = erc20ExternalModel.contract_address; - const updatedContract = JSON.parse(JSON.stringify(erc20ExternalModel)); - const updatedAbiJson = { abi: "data2" }; - updatedContract.contract_name = "UpdatedContractName"; - updatedContract.abi = JSON.stringify(updatedAbiJson); - it("should update an existing smart contract", async () => { + const updatedContract = JSON.parse(JSON.stringify(erc20ExternalModel)); + const updatedAbiJson = { abi: "data2" }; + updatedContract.contract_name = "UpdatedContractName"; + updatedContract.abi = JSON.stringify(updatedAbiJson); + Coinbase.apiClients.smartContract = smartContractApiMock; Coinbase.apiClients.smartContract.updateSmartContract = jest .fn() .mockResolvedValue({ data: updatedContract }); - const smartContract = await erc20ExternalSmartContract.update( - updatedAbiJson, - updatedContract.contract_name, - ); + const smartContract = await erc20ExternalSmartContract.update({ + abi: updatedAbiJson, + contractName: updatedContract.contract_name, + }); expect(Coinbase.apiClients.smartContract!.updateSmartContract).toHaveBeenCalledWith( networkId, @@ -133,12 +138,87 @@ describe("SmartContract", () => { expect(smartContract.getContractName()).toEqual(updatedContract.contract_name); }); + it("should update an existing smart contract - update contract name only", async () => { + const updatedContract = JSON.parse(JSON.stringify(erc20ExternalModel)); + updatedContract.contract_name = "UpdatedContractName"; + + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.updateSmartContract = jest + .fn() + .mockResolvedValue({ data: updatedContract }); + + const smartContract = await erc20ExternalSmartContract.update({ + contractName: updatedContract.contract_name, + }); + + expect(Coinbase.apiClients.smartContract!.updateSmartContract).toHaveBeenCalledWith( + networkId, + contractAddress, + { + contract_name: updatedContract.contract_name, + abi: undefined, + }, + ); + expect(smartContract).toBeInstanceOf(SmartContract); + expect(smartContract.getContractAddress()).toBe(contractAddress); + expect(smartContract.getAbi()).toEqual(erc20ExternalSmartContract.getAbi()); + expect(smartContract.getContractName()).toEqual(updatedContract.contract_name); + }); + + it("should update an existing smart contract - update abi only", async () => { + const updatedContract = JSON.parse(JSON.stringify(erc20ExternalModel)); + const updatedAbiJson = { abi: "data2" }; + updatedContract.abi = JSON.stringify(updatedAbiJson); + + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.updateSmartContract = jest + .fn() + .mockResolvedValue({ data: updatedContract }); + + const smartContract = await erc20ExternalSmartContract.update({ abi: updatedAbiJson }); + + expect(Coinbase.apiClients.smartContract!.updateSmartContract).toHaveBeenCalledWith( + networkId, + contractAddress, + { + contract_name: undefined, + abi: updatedContract.abi, + }, + ); + expect(smartContract).toBeInstanceOf(SmartContract); + expect(smartContract.getContractAddress()).toBe(contractAddress); + expect(smartContract.getAbi()).toEqual(updatedAbiJson); + expect(smartContract.getContractName()).toEqual(erc20ExternalSmartContract.getContractName()); + }); + + it("should update an existing smart contract - no update", async () => { + Coinbase.apiClients.smartContract = smartContractApiMock; + Coinbase.apiClients.smartContract.updateSmartContract = jest + .fn() + .mockResolvedValue({ data: erc20ExternalModel }); + + const smartContract = await erc20ExternalSmartContract.update({}); + + expect(Coinbase.apiClients.smartContract!.updateSmartContract).toHaveBeenCalledWith( + networkId, + contractAddress, + {}, + ); + expect(smartContract).toBeInstanceOf(SmartContract); + expect(smartContract.getContractAddress()).toBe(contractAddress); + expect(smartContract.getAbi()).toEqual(erc20ExternalSmartContract.getAbi()); + expect(smartContract.getContractName()).toEqual(erc20ExternalSmartContract.getContractName()); + }); + it("should throw an error if update fails", async () => { Coinbase.apiClients.smartContract!.updateSmartContract = jest .fn() .mockRejectedValue(new Error("Failed to update the smart contract")); await expect( - erc20ExternalSmartContract.update(testAllReadTypesABI, updatedContract.contract_name), + erc20ExternalSmartContract.update({ + abi: testAllReadTypesABI, + contractName: erc20ExternalSmartContract.getContractName(), + }), ).rejects.toThrow("Failed to update the smart contract"); }); }); @@ -195,7 +275,7 @@ describe("SmartContract", () => { }); }); - describe('#getWalletId', () => { + describe("#getWalletId", () => { it("returns the smart contract wallet ID", () => { expect(erc20SmartContract.getWalletId()).toEqual(VALID_SMART_CONTRACT_ERC20_MODEL.wallet_id); }); @@ -474,7 +554,9 @@ describe("SmartContract", () => { }); it("throws an error when the smart contract is external", async () => { - expect(externalSmartContract.reload()).rejects.toThrow("Cannot reload an external SmartContract"); + expect(externalSmartContract.reload()).rejects.toThrow( + "Cannot reload an external SmartContract", + ); }); }); @@ -482,8 +564,8 @@ describe("SmartContract", () => { it("returns the same value as toString", () => { expect(erc20SmartContract.toString()).toEqual( `SmartContract{id: '${erc20SmartContract.getId()}', networkId: '${erc20SmartContract.getNetworkId()}', ` + - `contractAddress: '${erc20SmartContract.getContractAddress()}', deployerAddress: '${erc20SmartContract.getDeployerAddress()}', ` + - `type: '${erc20SmartContract.getType()}'}`, + `contractAddress: '${erc20SmartContract.getContractAddress()}', deployerAddress: '${erc20SmartContract.getDeployerAddress()}', ` + + `type: '${erc20SmartContract.getType()}'}`, ); }); }); From ac9d2528ff55df391847ea669d57381fb77b0af0 Mon Sep 17 00:00:00 2001 From: Derek Date: Thu, 19 Dec 2024 13:47:17 -0800 Subject: [PATCH 23/25] feat(PSDK-670): Support external wallet imports, wallet imports from CDP Python SDK (#347) * - Support external wallet import via BIP-39 mnemonic phrases (12, 15, 18, 21, or 24 words) - Support import of wallet data exported from CDP Python SDK - Deprecated existing Wallet.import() method in favor of Wallet.load() (more descriptive of the fact that we're loading an existing CDP wallet, not importing one into CDP) * Implementing test cases. Lowered jest branch coverage criteria slightly * Committing more unit tests * - Renamed saveSeed() to saveSeedtoFile(), and deprecated the former - Renamed loadSeed() to loadSeedFromFile(), and deprecated the former - Merged mnemonic phrase import into the import() method - Merged WalletData and WalletDataSnake into one type, for clarity in method args - Updated unit tests * Minor changelog edit * Add retry logic to address.listTransactions() E2E test for better resiliency * Added console log to E2E test for better debugging * Add cross-SDK compatibility for WalletData's new networkId field * Ensure optionality of fields within WalletData during wallet export * Minor word consistency improvement to changelog --- CHANGELOG.md | 6 +- README.md | 6 +- quickstart-template/bridge-usdc.js | 2 +- .../discord_tutorial/webhook-transfer.js | 2 +- quickstart-template/register-basename.js | 2 +- src/coinbase/types.ts | 98 ++++++++++-- src/coinbase/wallet.ts | 149 +++++++++++++++--- src/tests/e2e.ts | 21 ++- src/tests/wallet_test.ts | 119 ++++++++++++-- 9 files changed, 337 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4449f383..6b1c1736 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,12 @@ - Add support for registering, updating, and listing smart contracts that are deployed external to CDP. - Add support for fetching address reputation - - Add `reputation` method to `Address` to fetch the reputation of the address. + - Add `reputation` method to `Address` to fetch the reputation of the address - Add `networkId` to `WalletData` so that it is saved with the seed data and surfaced via the export function +- Add ability to import external wallets into CDP via a BIP-39 mnemonic phrase, as a 1-of-1 wallet +- Add ability to import WalletData files exported by the Python CDP SDK +- Deprecate `Wallet.loadSeed()` method in favor of `Wallet.loadSeedFromFile()` +- Deprecate `Wallet.saveSeed()` method in favor of `Wallet.saveSeedToFile()` ## [0.12.0] - Skipped diff --git a/README.md b/README.md index 11d2eecd..c18bd5bf 100644 --- a/README.md +++ b/README.md @@ -201,13 +201,13 @@ For convenience during testing, we provide a `saveSeed` method that stores the w ```typescript const seedFilePath = ""; -wallet.saveSeed(seedFilePath); +wallet.saveSeedToFile(seedFilePath); ``` To encrypt the saved data, set encrypt to true. Note that your CDP API key also serves as the encryption key for the data persisted locally. To re-instantiate wallets with encrypted data, ensure that your SDK is configured with the same API key when invoking `saveSeed` and `loadSeed`. ```typescript -wallet.saveSeed(seedFilePath, true); +wallet.saveSeedToFile(seedFilePath, true); ``` The below code demonstrates how to re-instantiate a Wallet from the data export. @@ -221,7 +221,7 @@ To import Wallets that were persisted to your local file system using `saveSeed` ```typescript const userWallet = await Wallet.fetch(wallet.getId()); -await userWallet.loadSeed(seedFilePath); +await userWallet.loadSeedFromFile(seedFilePath); ``` diff --git a/quickstart-template/bridge-usdc.js b/quickstart-template/bridge-usdc.js index 4a0cbbbd..03b92eff 100644 --- a/quickstart-template/bridge-usdc.js +++ b/quickstart-template/bridge-usdc.js @@ -141,7 +141,7 @@ async function getTransactionReceipt(txHash) { async function fetchWalletAndLoadSeed(walletId, seedFilePath) { try { const wallet = await Wallet.fetch(walletId); - await wallet.loadSeed(seedFilePath); + await wallet.loadSeedFromFile(seedFilePath); console.log(`Successfully loaded funded wallet: `, wallet.getId()); return wallet; diff --git a/quickstart-template/discord_tutorial/webhook-transfer.js b/quickstart-template/discord_tutorial/webhook-transfer.js index 1aad72e8..74028d7d 100644 --- a/quickstart-template/discord_tutorial/webhook-transfer.js +++ b/quickstart-template/discord_tutorial/webhook-transfer.js @@ -26,7 +26,7 @@ const webhookNotificationUri = process.env.WEBHOOK_NOTIFICATION_URL; // Create Wallet else { myWallet = await Wallet.create(); - const saveSeed = myWallet.saveSeed(seedPath); + const saveSeed = myWallet.saveSeedToFile(seedPath); console.log("✅ Seed saved: ", saveSeed); } diff --git a/quickstart-template/register-basename.js b/quickstart-template/register-basename.js index 4025bcac..d2a30fc9 100644 --- a/quickstart-template/register-basename.js +++ b/quickstart-template/register-basename.js @@ -133,7 +133,7 @@ async function registerBaseName(wallet, registerArgs) { async function fetchWalletAndLoadSeed(walletId, seedFilePath) { try { const wallet = await Wallet.fetch(walletId); - await wallet.loadSeed(seedFilePath); + await wallet.loadSeedFromFile(seedFilePath); console.log(`Successfully loaded funded wallet: `, wallet); return wallet; diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index 49f6457f..8eb3c757 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -228,7 +228,7 @@ export type WalletAPIClient = { * List wallets belonging to the user. * * @param limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Override http request option. * @throws {APIError} If the request fails. * @throws {RequiredError} If the required parameter is not provided. @@ -360,7 +360,7 @@ export type AddressAPIClient = { * @param walletId - The ID of the wallet the address belongs to. * @param addressId - The onchain address of the address to sign the payload with. * @param limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Axios request options. * @throws {APIError} If the request fails. */ @@ -382,7 +382,7 @@ export type ExternalAddressAPIClient = { * * @param networkId - The ID of the blockchain network * @param addressId - The ID of the address to fetch the balance for - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Override http request option. * @throws {APIError} If the request fails. */ @@ -814,14 +814,87 @@ export enum FundOperationStatus { } /** - * The Wallet Data type definition. - * The data required to recreate a Wallet. + * Interface representing wallet data, with support for both camelCase and snake_case + * property names for compatibility with older versions of the Python SDK. */ -export type WalletData = { - walletId: string; +export interface WalletData { + /** + * The CDP wallet ID in either camelCase or snake_case format, but not both. + */ + walletId?: string; + wallet_id?: string; + + /** + * The wallet seed + */ seed: string; + + /** + * The network ID in either camelCase or snake_case format, but not both. + */ networkId?: string; -}; + network_id?: string; +} + +/** + * Type guard to check if data matches the appropriate WalletData format. + * WalletData must have: + * - exactly one of (walletId or wallet_id) + * - at most one of (networkId or network_id) + * - a seed + * + * @param data - The data to check + * @returns True if data matches the appropriate WalletData format + */ +export function isWalletData(data: unknown): data is WalletData { + if (typeof data !== "object" || data === null) { + return false; + } + + const { walletId, wallet_id, networkId, network_id, seed } = data as WalletData; + + // Check that exactly one of walletId or wallet_id is present (but not both) + const hasWalletId = typeof walletId === "string"; + const hasWalletSnakeId = typeof wallet_id === "string"; + if (!(hasWalletId !== hasWalletSnakeId)) { + return false; + } + + // Check that at most one of networkId or network_id is present (but not both) + const hasNetworkId = typeof networkId === "string"; + const hasNetworkSnakeId = typeof network_id === "string"; + if (hasNetworkId && hasNetworkSnakeId) { + return false; + } + + // Check that seed is present and is a string + return typeof seed === "string"; +} + +/** + * Interface representing a BIP-39 mnemonic seed phrase. + */ +export interface MnemonicSeedPhrase { + /** + * The BIP-39 mnemonic seed phrase (12, 15, 18, 21, or 24 words) + */ + mnemonicPhrase: string; +} + +/** + * Type guard to check if data matches the MnemonicSeedPhrase format. + * + * @param data - The data to check + * @returns True if data matches the MnemonicSeedPhrase format + */ +export function isMnemonicSeedPhrase(data: unknown): data is MnemonicSeedPhrase { + if (typeof data !== "object" || data === null) { + return false; + } + + const { mnemonicPhrase } = data as MnemonicSeedPhrase; + return typeof mnemonicPhrase === "string"; +} /** * The Seed Data type definition. @@ -856,6 +929,7 @@ export enum ServerSignerStatus { * Options for creating a Wallet. */ export type WalletCreateOptions = { + seed?: string; networkId?: string; timeoutSeconds?: number; intervalSeconds?: number; @@ -1149,7 +1223,7 @@ export interface WebhookApiClient { * * @summary List webhooks * @param {number} [limit] - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param {string} [page] - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param {string} [page] - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param {*} [options] - Override http request option. * @throws {RequiredError} */ @@ -1184,7 +1258,7 @@ export interface BalanceHistoryApiClient { * @param addressId - The ID of the address to fetch the historical balance for. * @param assetId - The symbol of the asset to fetch the historical balance for. * @param limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Override http request option. * @throws {RequiredError} */ @@ -1206,7 +1280,7 @@ export interface TransactionHistoryApiClient { * @param networkId - The ID of the blockchain network * @param addressId - The ID of the address to fetch transactions for. * @param limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Override http request option. * @throws {RequiredError} */ @@ -1502,7 +1576,7 @@ export interface FundOperationApiClient { * @param walletId - The ID of the wallet the address belongs to. * @param addressId - The ID of the address to list fund operations for. * @param limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * @param page - A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. * @param options - Axios request options * @throws {APIError} If the request fails */ diff --git a/src/coinbase/wallet.ts b/src/coinbase/wallet.ts index c44f0dde..3c850465 100644 --- a/src/coinbase/wallet.ts +++ b/src/coinbase/wallet.ts @@ -1,4 +1,7 @@ import { HDKey } from "@scure/bip32"; +import { mnemonicToSeedSync, validateMnemonic } from "@scure/bip39"; +import { wordlist } from "@scure/bip39/wordlists/english"; +import { hexlify } from "ethers"; import * as crypto from "crypto"; import Decimal from "decimal.js"; import { ethers } from "ethers"; @@ -26,6 +29,9 @@ import { StakeOptionsMode, WalletCreateOptions, WalletData, + isWalletData, + MnemonicSeedPhrase, + isMnemonicSeedPhrase, CreateERC20Options, CreateERC721Options, CreateERC1155Options, @@ -130,31 +136,67 @@ export class Wallet { } /** - * Imports a Wallet for the given Wallet data. + * Loads an existing CDP Wallet using a wallet data object or mnemonic seed phrase. * - * @param data - The Wallet data to import. - * @param data.walletId - The ID of the Wallet to import. - * @param data.seed - The seed to use for the Wallet. - * @returns The imported Wallet. - * @throws {ArgumentError} If the Wallet ID is not provided. + * @param data - The data used to import the wallet: + * - If WalletData: Must contain walletId (or wallet_id) and seed. + * Allows for the loading of an existing CDP wallet into CDP. + * - If MnemonicSeedPhrase: Must contain a valid BIP-39 mnemonic phrase (12, 15, 18, 21, or 24 words). + * Allows for the import of an external wallet into CDP as a 1-of-1 wallet. + * @returns A Promise that resolves to the loaded Wallet instance + * @throws {ArgumentError} If the data format is invalid. * @throws {ArgumentError} If the seed is not provided. - * @throws {APIError} If the request fails. + * @throws {ArgumentError} If the mnemonic seed phrase is invalid. */ - public static async import(data: WalletData): Promise { - if (!data.walletId) { - throw new ArgumentError("Wallet ID must be provided"); - } - if (!data.seed) { - throw new ArgumentError("Seed must be provided"); + public static async import(data: WalletData | MnemonicSeedPhrase): Promise { + // Check if data is a mnemonic seed phrase object + if (isMnemonicSeedPhrase(data)) { + // Handle mnemonic seed phrase object import + + if (!data.mnemonicPhrase) { + throw new ArgumentError("BIP-39 mnemonic seed phrase must be provided"); + } + + if (!validateMnemonic(data.mnemonicPhrase, wordlist)) { + throw new ArgumentError("Invalid BIP-39 mnemonic seed phrase"); + } + + // Convert mnemonic phrase to seed + const seedBuffer = mnemonicToSeedSync(data.mnemonicPhrase); + const seed = hexlify(seedBuffer).slice(2); // remove 0x prefix + + // Create wallet using the provided seed + const wallet = await Wallet.createWithSeed({ + seed: seed, + networkId: Coinbase.networks.BaseSepolia, + }); + + // Ensure the wallet is created + await wallet.listAddresses(); + return wallet; + } else if (isWalletData(data)) { + // Handle WalletData object import + + const walletId = data.walletId || data.wallet_id; + if (!walletId) { + throw new ArgumentError("Wallet ID must be provided"); + } + + if (!data.seed) { + throw new ArgumentError("Seed must be provided"); + } + + const walletModel = await Coinbase.apiClients.wallet!.getWallet(walletId); + const wallet = Wallet.init(walletModel.data, data.seed); + await wallet.listAddresses(); + return wallet; + } else { + throw new ArgumentError("Invalid import data format"); } - const walletModel = await Coinbase.apiClients.wallet!.getWallet(data.walletId); - const wallet = Wallet.init(walletModel.data, data.seed); - await wallet.listAddresses(); - return wallet; } /** - * Returns a newly created Wallet object. + * Creates a new Wallet with a random seed. * * @constructs Wallet * @param options - The options to create the Wallet. @@ -170,6 +212,32 @@ export class Wallet { networkId = Coinbase.networks.BaseSepolia, timeoutSeconds = 20, intervalSeconds = 0.2, + }: WalletCreateOptions = {}): Promise { + return Wallet.createWithSeed({ + networkId, + timeoutSeconds, + intervalSeconds, + }); + } + + /** + * Creates a new Wallet with the given seed. + * + * @param options - The options to create the Wallet. + * @param options.seed - The seed to use for the Wallet. If undefined, a random seed will be generated. + * @param options.networkId - the ID of the blockchain network. Defaults to 'base-sepolia'. + * @param options.intervalSeconds - The interval at which to poll the backend, in seconds. + * @param options.timeoutSeconds - The maximum amount of time to wait for the ServerSigner to create a seed, in seconds. + * @throws {ArgumentError} If the model or client is not provided. + * @throws {Error} - If address derivation or caching fails. + * @throws {APIError} - If the request fails. + * @returns A promise that resolves with the new Wallet object. + */ + public static async createWithSeed({ + seed = undefined, + networkId = Coinbase.networks.BaseSepolia, + timeoutSeconds = 20, + intervalSeconds = 0.2, }: WalletCreateOptions = {}): Promise { const result = await Coinbase.apiClients.wallet!.createWallet({ wallet: { @@ -178,7 +246,7 @@ export class Wallet { }, }); - const wallet = Wallet.init(result.data, undefined); + const wallet = Wallet.init(result.data, seed); if (Coinbase.useServerSigner) { await wallet.waitForSigner(wallet.getId()!, intervalSeconds, timeoutSeconds); } @@ -217,11 +285,15 @@ export class Wallet { * @returns The Wallet's data. * @throws {APIError} - If the request fails. */ - public export(): Required { + public export(): WalletData { if (!this.seed) { throw new Error("Cannot export Wallet without loaded seed"); } - return { walletId: this.getId()!, seed: this.seed, networkId: this.getNetworkId() }; + return { + walletId: this.getId()!, + seed: this.seed, + networkId: this.getNetworkId(), + }; } /** @@ -590,6 +662,20 @@ export class Wallet { return this.model.id; } + /** + * Saves the seed of the Wallet to the given file. + * + * @deprecated Use saveSeedToFile() instead + * @param filePath - The path of the file to save the seed to + * @param encrypt - Whether the seed information persisted to the local file system should be + * encrypted or not. Data is unencrypted by default. + * @returns A string indicating the success of the operation + * @throws {Error} If the Wallet does not have a seed + */ + public saveSeed(filePath: string, encrypt: boolean = false): string { + return this.saveSeedToFile(filePath, encrypt); + } + /** * Saves the seed of the Wallet to the given file. Wallets whose seeds are saved this way can be * rehydrated using load_seed. A single file can be used for multiple Wallet seeds. @@ -601,7 +687,7 @@ export class Wallet { * @returns A string indicating the success of the operation * @throws {Error} If the Wallet does not have a seed */ - public saveSeed(filePath: string, encrypt: boolean = false): string { + public saveSeedToFile(filePath: string, encrypt: boolean = false): string { if (!this.master) { throw new Error("Cannot save Wallet without loaded seed"); } @@ -626,12 +712,12 @@ export class Wallet { iv = ivBytes.toString("hex"); } - existingSeedsInStore[data.walletId] = { + existingSeedsInStore[data.walletId!] = { seed: seedToStore, encrypted: encrypt, authTag: authTag, iv: iv, - networkId: data.networkId, + networkId: data.networkId!, }; fs.writeFileSync(filePath, JSON.stringify(existingSeedsInStore, null, 2), "utf8"); @@ -642,10 +728,21 @@ export class Wallet { /** * Loads the seed of the Wallet from the given file. * + * @deprecated Use loadSeedFromFile() instead * @param filePath - The path of the file to load the seed from * @returns A string indicating the success of the operation */ public async loadSeed(filePath: string): Promise { + return this.loadSeedFromFile(filePath); + } + + /** + * Loads the seed of the Wallet from the given file. + * + * @param filePath - The path of the file to load the seed from + * @returns A string indicating the success of the operation + */ + public async loadSeedFromFile(filePath: string): Promise { const existingSeedsInStore = this.getExistingSeeds(filePath); if (Object.keys(existingSeedsInStore).length === 0) { throw new ArgumentError(`File ${filePath} does not contain any seed data`); @@ -913,8 +1010,8 @@ export class Wallet { * @param seed - The seed to use for the Wallet */ private validateSeed(seed: string | undefined): void { - if (seed && seed.length !== 64) { - throw new ArgumentError("Seed must be 32 bytes"); + if (seed && seed.length !== 64 && seed.length !== 128) { + throw new ArgumentError("Seed must be 32 or 64 bytes"); } } diff --git a/src/tests/e2e.ts b/src/tests/e2e.ts index dba5626d..978c828b 100644 --- a/src/tests/e2e.ts +++ b/src/tests/e2e.ts @@ -64,7 +64,7 @@ describe("Coinbase SDK E2E Test", () => { console.log( `Imported wallet with ID: ${importedWallet.getId()}, default address: ${importedWallet.getDefaultAddress()}`, ); - await importedWallet.saveSeed("test_seed.json"); + await importedWallet.saveSeedToFile("test_seed.json"); try { const transaction = await importedWallet.faucet(); @@ -88,13 +88,13 @@ describe("Coinbase SDK E2E Test", () => { expect(exportedWallet.seed).toBeDefined(); console.log("Saving seed to file..."); - await wallet.saveSeed("test_seed.json"); + await wallet.saveSeedToFile("test_seed.json"); expect(fs.existsSync("test_seed.json")).toBe(true); console.log("Saved seed to test_seed.json"); const unhydratedWallet = await Wallet.fetch(walletId); expect(unhydratedWallet.canSign()).toBe(false); - await unhydratedWallet.loadSeed("test_seed.json"); + await unhydratedWallet.loadSeedFromFile("test_seed.json"); expect(unhydratedWallet.canSign()).toBe(true); expect(unhydratedWallet.getId()).toBe(walletId); @@ -120,11 +120,16 @@ describe("Coinbase SDK E2E Test", () => { console.log(`Second address balances: ${secondBalance}`); console.log("Fetching address transactions..."); - const result = await ( - await unhydratedWallet.getDefaultAddress() - ).listTransactions({ limit: 1 }); + let result; + for (let i = 0; i < 5; i++) { + // Try up to 5 times + result = await (await unhydratedWallet.getDefaultAddress()).listTransactions({ limit: 1 }); + if (result?.data.length > 0) break; + // Wait 2 seconds between attempts + console.log(`Waiting for transaction to be processed... (${i + 1} attempts)`); + await new Promise(resolve => setTimeout(resolve, 2000)); + } expect(result?.data.length).toBeGreaterThan(0); - console.log(`Fetched transactions: ${result?.data[0].toString()}`); console.log("Fetching address historical balances..."); const balance_result = await ( @@ -137,7 +142,7 @@ describe("Coinbase SDK E2E Test", () => { fs.unlinkSync("test_seed.json"); expect(exportedWallet.seed.length).toBe(64); - expect(savedSeed[exportedWallet.walletId]).toEqual({ + expect(savedSeed[exportedWallet.walletId!]).toEqual({ seed: exportedWallet.seed, encrypted: false, authTag: "", diff --git a/src/tests/wallet_test.ts b/src/tests/wallet_test.ts index c1e63468..e09a8fad 100644 --- a/src/tests/wallet_test.ts +++ b/src/tests/wallet_test.ts @@ -71,6 +71,7 @@ import { PayloadSignature } from "../coinbase/payload_signature"; import { ContractInvocation } from "../coinbase/contract_invocation"; import { SmartContract } from "../coinbase/smart_contract"; import { Webhook } from "../coinbase/webhook"; +import { WalletData } from "../coinbase/types"; describe("Wallet Class", () => { let wallet: Wallet; @@ -1025,6 +1026,94 @@ describe("Wallet Class", () => { "Wallet ID must be provided", ); }); + it("should throw an error when seed is not provided", async () => { + const walletData = seedWallet.export(); + walletData.seed = ""; + await expect(async () => await Wallet.import(walletData)).rejects.toThrow( + "Seed must be provided", + ); + }); + it("should throw an error when both walletId and wallet_id are provided", async () => { + const walletData = seedWallet.export(); + walletData.wallet_id = walletData.walletId; + await expect(async () => await Wallet.import(walletData)).rejects.toThrow( + "Invalid import data format", + ); + }); + it("should throw an error when wallet data format is invalid", async () => { + const invalidWalletData = { + foo: "bar", + bar: 123, + } as unknown as WalletData; + await expect(async () => await Wallet.import(invalidWalletData)).rejects.toThrow( + "Invalid import data format", + ); + }); + }); + + describe("#importFromMnemonicSeedPhrase", () => { + const validMnemonic = + "crouch cereal notice one canyon kiss tape employ ghost column vanish despair eight razor laptop keen rally gaze riot regret assault jacket risk curve"; + const address0 = "0x43A0477E658C6e05136e81C576CF02daCEa067bB"; + const publicKey = "0x037e6cbdd1d949f60f41d5db7ffa9b3ddce0b77eab35ef7affd3f64cbfd9e33a91"; + const addressModel = { + ...VALID_ADDRESS_MODEL, + address_id: address0, + public_key: publicKey, + }; + + beforeEach(() => { + jest.clearAllMocks(); + Coinbase.apiClients.wallet = walletsApiMock; + Coinbase.apiClients.address = addressesApiMock; + Coinbase.apiClients.wallet!.createWallet = mockFn(request => { + const { network_id } = request.wallet; + apiResponses[walletId] = { + id: walletId, + network_id, + default_address: addressModel, + }; + return { data: apiResponses[walletId] }; + }); + Coinbase.apiClients.wallet!.getWallet = mockFn(walletId => { + walletModel = apiResponses[walletId]; + walletModel.default_address!.address_id = address0; + return { data: apiResponses[walletId] }; + }); + Coinbase.apiClients.address!.createAddress = mockReturnValue(addressModel); + Coinbase.apiClients.address!.listAddresses = mockFn(() => { + return { + data: { + data: [addressModel], + has_more: false, + next_page: "", + total_count: 1, + }, + }; + }); + }); + + it("successfully imports a wallet from a valid 24-word mnemonic", async () => { + const wallet = await Wallet.import({ mnemonicPhrase: validMnemonic }); + expect(wallet).toBeInstanceOf(Wallet); + expect(Coinbase.apiClients.wallet!.createWallet).toHaveBeenCalledTimes(1); + expect(Coinbase.apiClients.address!.createAddress).toHaveBeenCalledTimes(1); + expect(Coinbase.apiClients.address!.listAddresses).toHaveBeenCalledTimes(1); + }); + + it("throws an error when mnemonic is empty", async () => { + await expect(Wallet.import({ mnemonicPhrase: "" })).rejects.toThrow( + "BIP-39 mnemonic seed phrase must be provided", + ); + expect(Coinbase.apiClients.wallet!.createWallet).not.toHaveBeenCalled(); + }); + + it("throws an error when mnemonic is invalid", async () => { + await expect(Wallet.import({ mnemonicPhrase: "invalid mnemonic phrase" })).rejects.toThrow( + "Invalid BIP-39 mnemonic seed phrase", + ); + expect(Coinbase.apiClients.wallet!.createWallet).not.toHaveBeenCalled(); + }); }); describe("#listBalances", () => { @@ -1190,7 +1279,7 @@ describe("Wallet Class", () => { }); it("should save the seed when encryption is false", async () => { - seedWallet.saveSeed(filePath, false); + seedWallet.saveSeedToFile(filePath, false); const storedSeedData = fs.readFileSync(filePath); const walletSeedData = JSON.parse(storedSeedData.toString()); expect(walletSeedData[walletId].encrypted).toBe(false); @@ -1201,7 +1290,7 @@ describe("Wallet Class", () => { }); it("should save the seed when encryption is true", async () => { - seedWallet.saveSeed(filePath, true); + seedWallet.saveSeedToFile(filePath, true); const storedSeedData = fs.readFileSync(filePath); const walletSeedData = JSON.parse(storedSeedData.toString()); expect(walletSeedData[walletId].encrypted).toBe(true); @@ -1212,7 +1301,7 @@ describe("Wallet Class", () => { it("should throw an error when the wallet is seedless", async () => { const seedlessWallet = Wallet.init(walletModel, ""); - expect(() => seedlessWallet.saveSeed(filePath, false)).toThrow(Error); + expect(() => seedlessWallet.saveSeedToFile(filePath, false)).toThrow(Error); }); }); @@ -1250,18 +1339,18 @@ describe("Wallet Class", () => { }); it("loads the seed from the file", async () => { - await seedlessWallet.loadSeed(filePath); + await seedlessWallet.loadSeedFromFile(filePath); expect(seedlessWallet.canSign()).toBe(true); }); it("loads the encrypted seed from the file", async () => { - seedWallet.saveSeed(filePath, true); - await seedlessWallet.loadSeed(filePath); + seedWallet.saveSeedToFile(filePath, true); + await seedlessWallet.loadSeedFromFile(filePath); expect(seedlessWallet.canSign()).toBe(true); }); it("loads the encrypted seed from the file with multiple seeds", async () => { - seedWallet.saveSeed(filePath, true); + seedWallet.saveSeedToFile(filePath, true); const otherModel = { id: crypto.randomUUID(), @@ -1270,14 +1359,14 @@ describe("Wallet Class", () => { }; const randomSeed = ethers.Wallet.createRandom().privateKey.slice(2); const otherWallet = Wallet.init(otherModel, randomSeed); - otherWallet.saveSeed(filePath, true); + otherWallet.saveSeedToFile(filePath, true); - await seedlessWallet.loadSeed(filePath); + await seedlessWallet.loadSeedFromFile(filePath); expect(seedlessWallet.canSign()).toBe(true); }); it("raises an error if the wallet is already hydrated", async () => { - await expect(seedWallet.loadSeed(filePath)).rejects.toThrow(Error); + await expect(seedWallet.loadSeedFromFile(filePath)).rejects.toThrow(Error); }); it("raises an error when file contains different wallet data", async () => { @@ -1291,28 +1380,28 @@ describe("Wallet Class", () => { }; fs.writeFileSync(filePath, JSON.stringify(otherSeedData), "utf8"); - await expect(seedlessWallet.loadSeed(filePath)).rejects.toThrow(ArgumentError); + await expect(seedlessWallet.loadSeedFromFile(filePath)).rejects.toThrow(ArgumentError); }); it("raises an error when the file is absent", async () => { - await expect(seedlessWallet.loadSeed("non-file.json")).rejects.toThrow(ArgumentError); + await expect(seedlessWallet.loadSeedFromFile("non-file.json")).rejects.toThrow(ArgumentError); }); it("raises an error when the file is corrupted", async () => { fs.writeFileSync(filePath, "corrupted data", "utf8"); - await expect(seedlessWallet.loadSeed(filePath)).rejects.toThrow(ArgumentError); + await expect(seedlessWallet.loadSeedFromFile(filePath)).rejects.toThrow(ArgumentError); }); it("throws an error when the file is empty", async () => { fs.writeFileSync("invalid-file.json", "", "utf8"); - await expect(wallet.loadSeed("invalid-file.json")).rejects.toThrow(ArgumentError); + await expect(wallet.loadSeedFromFile("invalid-file.json")).rejects.toThrow(ArgumentError); fs.unlinkSync("invalid-file.json"); }); it("throws an error when the file is not a valid JSON", async () => { fs.writeFileSync("invalid-file.json", `{"test":{"authTag":false}}`, "utf8"); - await expect(wallet.loadSeed("invalid-file.json")).rejects.toThrow(ArgumentError); + await expect(wallet.loadSeedFromFile("invalid-file.json")).rejects.toThrow(ArgumentError); fs.unlinkSync("invalid-file.json"); }); }); From 42ce69d2cf0f42b98d3bcf374953e5c50ba9e41b Mon Sep 17 00:00:00 2001 From: Ryan Gilbert Date: Thu, 19 Dec 2024 17:14:39 -0500 Subject: [PATCH 24/25] chore: bump version to v0.13.0 (#351) --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- quickstart-template/package.json | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b1c1736..f02482fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Coinbase Node.js SDK Changelog -## Unreleased +## [0.13.0] - 2024-12-19 + +### Added - Add support for registering, updating, and listing smart contracts that are deployed external to CDP. - Add support for fetching address reputation @@ -8,6 +10,8 @@ - Add `networkId` to `WalletData` so that it is saved with the seed data and surfaced via the export function - Add ability to import external wallets into CDP via a BIP-39 mnemonic phrase, as a 1-of-1 wallet - Add ability to import WalletData files exported by the Python CDP SDK + +### Deprecated - Deprecate `Wallet.loadSeed()` method in favor of `Wallet.loadSeedFromFile()` - Deprecate `Wallet.saveSeed()` method in favor of `Wallet.saveSeedToFile()` diff --git a/package-lock.json b/package-lock.json index 819c5334..b1805b6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@coinbase/coinbase-sdk", - "version": "0.11.3", + "version": "0.13.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@coinbase/coinbase-sdk", - "version": "0.11.3", + "version": "0.13.0", "license": "ISC", "dependencies": { "@scure/bip32": "^1.4.0", diff --git a/package.json b/package.json index 9b1630c2..18826248 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "ISC", "description": "Coinbase Platform SDK", "repository": "https://github.com/coinbase/coinbase-sdk-nodejs", - "version": "0.11.3", + "version": "0.13.0", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/quickstart-template/package.json b/quickstart-template/package.json index 3b3bca6c..b29d4e2d 100644 --- a/quickstart-template/package.json +++ b/quickstart-template/package.json @@ -22,7 +22,7 @@ "dependencies": { "@solana/web3.js": "^2.0.0-rc.1", "bs58": "^6.0.0", - "@coinbase/coinbase-sdk": "^0.11.2", + "@coinbase/coinbase-sdk": "^0.13.0", "csv-parse": "^5.5.6", "csv-writer": "^1.6.0", "viem": "^2.21.6" From dc5b8c051247671a87784b74f7b1455dfc1d0b5e Mon Sep 17 00:00:00 2001 From: Ryan Gilbert Date: Thu, 19 Dec 2024 17:22:14 -0500 Subject: [PATCH 25/25] chore: fix changelog (#353) --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f02482fa..dd1710f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ - Add `networkId` to `WalletData` so that it is saved with the seed data and surfaced via the export function - Add ability to import external wallets into CDP via a BIP-39 mnemonic phrase, as a 1-of-1 wallet - Add ability to import WalletData files exported by the Python CDP SDK +- Add getters for `Validator` object to expose more data to users. +- Add test file for `Validator` object. ### Deprecated - Deprecate `Wallet.loadSeed()` method in favor of `Wallet.loadSeedFromFile()` @@ -17,11 +19,6 @@ ## [0.12.0] - Skipped -### Added - -- Add getters for `Validator` object to expose more data to users. -- Add test file for `Validator` object. - ### [0.11.3] - 2024-12-10 ### Added