Wallet
@node-fi/sdk-core / Exports / Wallet
Class: Wallet<T>
Type parameters
Name | Type |
---|---|
T | extends Signer = Signer |
Hierarchy
Wallet
↳
EOA
Table of contents
Constructors
Properties
Accessors
Methods
- connect
- fetchBackendPortfolioValue
- fetchFromWalletService
- fetchPaymentRequests
- fetchPortfolioRaw
- fulfillPaymentRequest
- getHistoricalTransactions
- register
- requestPayment
- setFeeCurrency
- signAndSendContractTransactions
- signAndSendNodeTransactions
- signAndSendTransaction
- signAndSendTransactions
- signMessage
- signMessageRaw
- transferToken
- isWallet
- loadAsync
- loadFromConfig
Constructors
constructor
• new Wallet<T
>(_signer
, apiKey
, homeChain?
, address?
, wid?
)
Type parameters
Name | Type |
---|---|
T | extends Signer <T > = Signer |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
_signer | undefined | T | undefined | Signer to use for signing transactions |
apiKey | string | undefined | string, API key required to authenticate payloads |
homeChain | ChainId | ChainId.Celo | homechain for the wallet. Default is Celo for now |
address? | string | undefined | address of the wallet. EOA or smart wallet |
wid? | number | undefined | wid of the wallet. Used for node wallet backend |
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:157
Properties
_address
• Private
_address: undefined
| string
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:142
_apiKey
• Private
_apiKey: string
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:145
_chain
• Private
_chain: ChainId
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:143
_isNodeWallet
• Private
_isNodeWallet: boolean
= true
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:141
_provider
• Private
_provider: Provider
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:147
_signer
• Private
_signer: undefined
| T
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:158
_wid
• Private
Optional
_wid: number
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:146
network
• Optional
network: Network
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:144
Accessors
address
• get
address(): undefined
| string
Returns
undefined
| string
Address of the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:192
apiKey
• get
apiKey(): string
Returns
string
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:227
chain
• get
chain(): ChainId
Returns
ChainId
Home chain for the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:209
feeCurrency
• get
feeCurrency(): undefined
| string
Returns
undefined
| string
Fee currency for the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:199
provider
• get
provider(): Provider
Returns
Provider
Provider for the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:223
signer
• get
signer(): undefined
| T
Returns
undefined
| T
Signer for the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:185
wid
• get
wid(): undefined
| number
Returns
undefined
| number
Wid of the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:216
Methods
connect
▸ connect(signerOrProviderOrAddress
): Promise
<Wallet
<T
>>
Connect a signer to the wallet
Parameters
Name | Type | Description |
---|---|---|
signerOrProviderOrAddress | T | Signer, provider or address to connect |
Returns
Promise
<Wallet
<T
>>
Wallet instance
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:282
▸ connect(signerOrProviderOrAddress
): Promise
<Wallet
<JsonRpcSigner
>>
Parameters
Name | Type |
---|---|
signerOrProviderOrAddress | JsonRpcProvider |
Returns
Promise
<Wallet
<JsonRpcSigner
>>
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:283
fetchBackendPortfolioValue
▸ fetchBackendPortfolioValue(interval
, timeframe
, currency?
): Promise
<undefined
| { time
: number
; total
: number
}[]>
Fetches the wallet's historical portfolio for a given time period of resolution. Portfolio value is given in the declared currency code.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
interval | Interval | undefined | time interval between ticks |
timeframe | TimeFrame | undefined | timeframe on which to view historical portfolio value |
currency | string | "usd" | base currency code for the query |
Returns
Promise
<undefined
| { time
: number
; total
: number
}[]>
an array of portfolio values at specific times, where the time in between ticks corresponds to interval
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:554
fetchFromWalletService
▸ fetchFromWalletService(): Promise
<boolean
>
Fetches details on the wallet from the Node Finace wallet service. Includes metadata set by developer.
Returns
Promise
<boolean
>
Wallet object
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:368
fetchPaymentRequests
▸ fetchPaymentRequests<MetaDataShape
>(getToken
, opts?
): Promise
<{ pageInfo
: PageInfo
; requests
: PaymentRequest
<MetaDataShape
>[] }>
Fetches payment requests for a wallet. Can fetch pending, completed, or all. Default pagination is page 0, with 10 per page.
Type parameters
Name | Type |
---|---|
MetaDataShape | extends Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
getToken | (address : string ) => Token | Callback to fetch a token given its address |
opts? | Object | Options for the query, including request type, page, and count per page |
opts.count? | number | - |
opts.page? | number | - |
opts.type? | "all" | "pending" | "completed" | - |
Returns
Promise
<{ pageInfo
: PageInfo
; requests
: PaymentRequest
<MetaDataShape
>[] }>
List of payment requests for the wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:485
fetchPortfolioRaw
▸ fetchPortfolioRaw(opts
): Promise
<{ time
: number
; total
: number
}[]>
Parameters
Name | Type |
---|---|
opts | Object |
opts.chain? | number |
opts.currency? | string |
opts.endTime? | number |
opts.resolution? | Interval |
opts.startTime? | number |
Returns
Promise
<{ time
: number
; total
: number
}[]>
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:569
fulfillPaymentRequest
▸ fulfillPaymentRequest<T
>(request
, amount
): Promise
<{ receipt
: TransactionResponse
}>
Handles repaying a portion, or all of, a payment request.
Type parameters
Name | Type |
---|---|
T | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
request | PaymentRequest <T > | PaymentRequest object to fulfill |
amount | TokenAmount | The total token amount to pay towards this payment request. Does not have to equal the remaining amount. |
Returns
Promise
<{ receipt
: TransactionResponse
}>
Request after crediting payment, and receipt of payment
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:437
getHistoricalTransactions
▸ getHistoricalTransactions(getTokens
, opts?
): Promise
<TokenTransactionBase
[]>
Parameters
Name | Type | Description |
---|---|---|
getTokens | (address : string ) => Token | Callback to fetch a token given its address |
opts? | Object | Page options and currency code options |
opts.localCurrencyCode? | string | - |
opts.page? | number | - |
opts.perPage? | number | - |
Returns
Promise
<TokenTransactionBase
[]>
List of transactions for the wallet, additionally with local value transacted
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:308
register
▸ register(metadata?
, optInTracking?
): Promise
<Wallet
<T
>>
Parameters
Name | Type | Default value | Description |
---|---|---|---|
metadata | Object | {} | additional metadata to be stored with the wallet |
optInTracking | boolean | false | opt in to tracking |
Returns
Promise
<Wallet
<T
>>
Wallet object
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:333
requestPayment
▸ requestPayment<T
>(from
, amount
, deadline?
, metadata?
): Promise
<PaymentRequest
<T
>>
Authenticates and creates a new payment request
Type parameters
Name | Type |
---|---|
T | extends Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
from | string | Address to request payment from |
amount | TokenAmount | Token and amount to request |
deadline? | Date | Optional date that payment must be fulfilled |
metadata? | T | Additional metadata to store regarding the request |
Returns
Promise
<PaymentRequest
<T
>>
PaymentRequest object corresponding to the newly-created request
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:464
setFeeCurrency
▸ setFeeCurrency(tokenAddress
): string
Set the default gas currency. Only applicable on Celo and Alfajores, otherwise will fail
Parameters
Name | Type | Description |
---|---|---|
tokenAddress | string | Token address to use to pay gas fees. |
Returns
string
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:420
signAndSendContractTransactions
▸ signAndSendContractTransactions(descriptions
, opts?
): Promise
<TransactionReceipt
>
Deprecated
use wallet.signer to sign transactions instead
Parameters
Name | Type | Description |
---|---|---|
descriptions | ContractTransaction [] | descriptions of transactions to sign and process |
opts? | TransactionOptions | - |
Returns
Promise
<TransactionReceipt
>
transaction receipt from executed txn
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:599
signAndSendNodeTransactions
▸ signAndSendNodeTransactions(transactions
, opts?
): Promise
<TransactionReceipt
>
Deprecated
use wallet.signer to sign transactions instead
Parameters
Name | Type | Description |
---|---|---|
transactions | NodeWalletTransaction [] | transaction descriptions in a more readable format |
opts? | TransactionOptions | - |
Returns
Promise
<TransactionReceipt
>
transaction receipt
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:625
signAndSendTransaction
▸ signAndSendTransaction(transaction
, opts?
): Promise
<TransactionReceipt
>
Deprecated
use wallet.signer to sign transactions instead
Parameters
Name | Type |
---|---|
transaction | TransactionRequest | TransactionRequest [] |
opts? | TransactionOptions |
Returns
Promise
<TransactionReceipt
>
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:642
signAndSendTransactions
▸ signAndSendTransactions(transactions
, opts?
): Promise
<TransactionReceipt
[]>
Deprecated
use wallet.signer to sign transactions instead
Parameters
Name | Type |
---|---|
transactions | TransactionRequest [] |
opts? | TransactionOptions |
Returns
Promise
<TransactionReceipt
[]>
transaction receipt
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:674
signMessage
▸ signMessage(data
): Promise
<Signature
>
Parameters
Name | Type | Description |
---|---|---|
data | string | Message to sign |
Returns
Promise
<Signature
>
A Sign object, which contains all fields needed to recompute original signer, as well as the signed message
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:539
signMessageRaw
▸ signMessageRaw(data
): Promise
<string
>
Parameters
Name | Type | Description |
---|---|---|
data | string | Message to sign |
Returns
Promise
<string
>
A Sign object, which contains all fields needed to recompute original signer, as well as the signed message
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:529
transferToken
▸ transferToken(token
, amount
, recipient
, overrides?
): Promise
<TransactionResponse
>
Sends a token from this wallet to any other address.
Parameters
Name | Type | Description |
---|---|---|
token | string | Token | Token to send |
amount | BigintIsh | Amount to send |
recipient | string | Recipient of transfer |
overrides | Omit <TransactionRequest , "data" | "to" | "value" > | - |
Returns
Promise
<TransactionResponse
>
Receipt of transaction of sending the token
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:396
isWallet
▸ Static
isWallet(o
): o is Wallet<Signer>
Parameters
Name | Type | Description |
---|---|---|
o | unknown | unknown object |
Returns
o is Wallet<Signer>
true if the wallet is a node wallet
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:236
loadAsync
▸ Static
loadAsync<T
>(getSigner
, apiKey
): Promise
<undefined
| Wallet
<Signer
>>
Type parameters
Name | Type |
---|---|
T | extends Signer <T > |
Parameters
Name | Type | Description |
---|---|---|
getSigner | () => T | Promise <T > | Callback to fetch the signer |
apiKey | string | API key required to authenticate payloads |
Returns
Promise
<undefined
| Wallet
<Signer
>>
Wallet instance
Defined in
packages/sdk-core/src/wallet/NodeWallet.ts:245
loadFromConfig
▸ Static
loadFromConfig(config
, chain
, apiKey
): Promise
<undefined
| Wallet
<Signer
>>
Load a wallet from a config object
Parameters
Name | Type | Description |
---|---|---|
config | WalletConfig | WalletConfig object |
chain | ChainId | ChainId of the wallet |
apiKey | string | API key required to authenticate payloads |
Returns
Promise
<undefined
| Wallet
<Signer
>>
Wallet instance