From 1071b2915a71148bada5a8b214ed00fb9dba97e5 Mon Sep 17 00:00:00 2001 From: Jacob Daitzman Date: Wed, 31 Mar 2021 11:01:30 -0400 Subject: [PATCH 1/4] Add support for bigint types for `amount` and `assetTotal` fields --- src/transaction.ts | 8 ++++---- src/types/transactions/base.ts | 4 ++-- src/types/transactions/encoded.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/transaction.ts b/src/transaction.ts index 536d64fa2..65c0df14b 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -56,7 +56,7 @@ interface TransactionStorageStructure from: string | Address; to: string | Address; fee: number; - amount: number; + amount: number | bigint; firstRound: number; lastRound: number; note?: Uint8Array; @@ -70,7 +70,7 @@ interface TransactionStorageStructure voteLast: number; voteKeyDilution: number; assetIndex: number; - assetTotal: number; + assetTotal: number | bigint; assetDecimals: number; assetDefaultFrozen: boolean; assetManager: string | Address; @@ -114,7 +114,7 @@ export class Transaction implements TransactionStorageStructure { from: Address; to: Address; fee: number; - amount: number; + amount: number | bigint; firstRound: number; lastRound: number; note?: Uint8Array; @@ -128,7 +128,7 @@ export class Transaction implements TransactionStorageStructure { voteLast: number; voteKeyDilution: number; assetIndex: number; - assetTotal: number; + assetTotal: number | bigint; assetDecimals: number; assetDefaultFrozen: boolean; assetManager: Address; diff --git a/src/types/transactions/base.ts b/src/types/transactions/base.ts index 633f776c4..9c9dc1587 100644 --- a/src/types/transactions/base.ts +++ b/src/types/transactions/base.ts @@ -141,7 +141,7 @@ export interface TransactionParams { /** * Integer amount to send */ - amount: number; + amount: number | bigint; /** * Integer first protocol round on which this txn is valid @@ -211,7 +211,7 @@ export interface TransactionParams { /** * Total supply of the asset */ - assetTotal: number; + assetTotal: number | bigint; /** * Integer number of decimals for asset unit calcuation diff --git a/src/types/transactions/encoded.ts b/src/types/transactions/encoded.ts index 291163a82..cda92f2d2 100644 --- a/src/types/transactions/encoded.ts +++ b/src/types/transactions/encoded.ts @@ -6,7 +6,7 @@ export interface EncodedAssetParams { /** * assetTotal */ - t: number; + t: number | bigint; /** * assetDefaultFrozen @@ -140,12 +140,12 @@ export interface EncodedTransaction { /** * amount */ - amt?: number; + amt?: number | bigint; /** * amount (but for asset transfers) */ - aamt?: number; + aamt?: number | bigint; /** * closeRemainderTo From 6da7c21fb8ce1f71af1be13482807e894f51d36f Mon Sep 17 00:00:00 2001 From: Jacob Daitzman Date: Wed, 31 Mar 2021 16:24:44 -0400 Subject: [PATCH 2/4] Mark `assetMetadataHash` property as optional --- src/makeTxn.ts | 4 ++-- src/transaction.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/makeTxn.ts b/src/makeTxn.ts index 873808f14..694b2c34d 100644 --- a/src/makeTxn.ts +++ b/src/makeTxn.ts @@ -318,7 +318,7 @@ export function makeAssetCreateTxnWithSuggestedParams( unitName: AssetCreateTxn['assetUnitName'], assetName: AssetCreateTxn['assetName'], assetURL: AssetCreateTxn['assetURL'], - assetMetadataHash: AssetCreateTxn['assetMetadataHash'], + assetMetadataHash: AssetCreateTxn['assetMetadataHash'] | undefined, suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetCreateTxn['reKeyTo'] ) { @@ -386,7 +386,7 @@ export function makeAssetCreateTxn( unitName: AssetCreateTxn['assetUnitName'], assetName: AssetCreateTxn['assetName'], assetURL: AssetCreateTxn['assetURL'], - assetMetadataHash: AssetCreateTxn['assetMetadataHash'], + assetMetadataHash?: AssetCreateTxn['assetMetadataHash'], rekeyTo?: AssetCreateTxn['reKeyTo'] ) { const suggestedParams: SuggestedParams = { diff --git a/src/transaction.ts b/src/transaction.ts index 65c0df14b..afe683e95 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -80,7 +80,7 @@ interface TransactionStorageStructure assetUnitName: string; assetName: string; assetURL: string; - assetMetadataHash: string | Uint8Array; + assetMetadataHash?: string | Uint8Array; freezeAccount: string | Address; freezeState: boolean; assetRevocationTarget?: string | Address; @@ -138,7 +138,7 @@ export class Transaction implements TransactionStorageStructure { assetUnitName: string; assetName: string; assetURL: string; - assetMetadataHash: Uint8Array; + assetMetadataHash?: Uint8Array; freezeAccount: Address; freezeState: boolean; assetRevocationTarget?: Address; From 0272f8f5284497cd9d41023ba132c193bf3d5d51 Mon Sep 17 00:00:00 2001 From: Jacob Daitzman Date: Wed, 31 Mar 2021 16:25:29 -0400 Subject: [PATCH 3/4] Switch from `.d.ts` extension to `.ts` so files are included during build --- src/types/{account.d.ts => account.ts} | 0 src/types/{address.d.ts => address.ts} | 0 src/types/{multisig.d.ts => multisig.ts} | 0 src/types/transactions/{application.d.ts => application.ts} | 0 src/types/transactions/{asset.d.ts => asset.ts} | 0 src/types/transactions/base.ts | 2 +- src/types/transactions/{builder.d.ts => builder.ts} | 0 src/types/transactions/{keyreg.d.ts => keyreg.ts} | 0 src/types/transactions/{payment.d.ts => payment.ts} | 0 src/types/{utils.d.ts => utils.ts} | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename src/types/{account.d.ts => account.ts} (100%) rename src/types/{address.d.ts => address.ts} (100%) rename src/types/{multisig.d.ts => multisig.ts} (100%) rename src/types/transactions/{application.d.ts => application.ts} (100%) rename src/types/transactions/{asset.d.ts => asset.ts} (100%) rename src/types/transactions/{builder.d.ts => builder.ts} (100%) rename src/types/transactions/{keyreg.d.ts => keyreg.ts} (100%) rename src/types/transactions/{payment.d.ts => payment.ts} (100%) rename src/types/{utils.d.ts => utils.ts} (100%) diff --git a/src/types/account.d.ts b/src/types/account.ts similarity index 100% rename from src/types/account.d.ts rename to src/types/account.ts diff --git a/src/types/address.d.ts b/src/types/address.ts similarity index 100% rename from src/types/address.d.ts rename to src/types/address.ts diff --git a/src/types/multisig.d.ts b/src/types/multisig.ts similarity index 100% rename from src/types/multisig.d.ts rename to src/types/multisig.ts diff --git a/src/types/transactions/application.d.ts b/src/types/transactions/application.ts similarity index 100% rename from src/types/transactions/application.d.ts rename to src/types/transactions/application.ts diff --git a/src/types/transactions/asset.d.ts b/src/types/transactions/asset.ts similarity index 100% rename from src/types/transactions/asset.d.ts rename to src/types/transactions/asset.ts diff --git a/src/types/transactions/base.ts b/src/types/transactions/base.ts index 9c9dc1587..69029a804 100644 --- a/src/types/transactions/base.ts +++ b/src/types/transactions/base.ts @@ -260,7 +260,7 @@ export interface TransactionParams { /** * Uint8Array or UTF-8 string representation of a hash commitment with respect to the asset. Must be exactly 32 bytes long. */ - assetMetadataHash: Uint8Array | string; + assetMetadataHash?: Uint8Array | string; /** * String representation of Algorand address being frozen or unfrozen diff --git a/src/types/transactions/builder.d.ts b/src/types/transactions/builder.ts similarity index 100% rename from src/types/transactions/builder.d.ts rename to src/types/transactions/builder.ts diff --git a/src/types/transactions/keyreg.d.ts b/src/types/transactions/keyreg.ts similarity index 100% rename from src/types/transactions/keyreg.d.ts rename to src/types/transactions/keyreg.ts diff --git a/src/types/transactions/payment.d.ts b/src/types/transactions/payment.ts similarity index 100% rename from src/types/transactions/payment.d.ts rename to src/types/transactions/payment.ts diff --git a/src/types/utils.d.ts b/src/types/utils.ts similarity index 100% rename from src/types/utils.d.ts rename to src/types/utils.ts From 9f13e6e1b0bddabdf78ac309c4e0c9d7fc61af1d Mon Sep 17 00:00:00 2001 From: Jacob Daitzman Date: Wed, 31 Mar 2021 16:29:54 -0400 Subject: [PATCH 4/4] Support string port parameters in client classes --- src/client/client.ts | 2 +- src/client/kmd.ts | 2 +- src/client/v2/algod/algod.ts | 2 +- src/client/v2/indexer/indexer.ts | 2 +- src/client/v2/serviceClient.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 9a9d01796..568d43723 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -117,7 +117,7 @@ export default class HTTPClient { constructor( tokenHeader: TokenHeader, baseServer: string, - port?: number, + port?: string | number, private defaultHeaders: Record = {} ) { // Do not need colon if port is empty diff --git a/src/client/kmd.ts b/src/client/kmd.ts index 44ac37d21..8ff72561e 100644 --- a/src/client/kmd.ts +++ b/src/client/kmd.ts @@ -6,7 +6,7 @@ export default class Kmd extends ServiceClient { constructor( token: string | KMDTokenHeader | CustomTokenHeader, baseServer = 'http://127.0.0.1', - port = 7833, + port: string | number = 7833, headers = {} ) { super('X-KMD-API-Token', token, baseServer, port, headers); diff --git a/src/client/v2/algod/algod.ts b/src/client/v2/algod/algod.ts index 0e4e81161..caa9af527 100644 --- a/src/client/v2/algod/algod.ts +++ b/src/client/v2/algod/algod.ts @@ -24,7 +24,7 @@ export default class AlgodClient extends ServiceClient { constructor( token: string | AlgodTokenHeader | CustomTokenHeader, baseServer = 'http://r2.algorand.network', - port = 4180, + port: string | number = 4180, headers = {} ) { super('X-Algo-API-Token', token, baseServer, port, headers); diff --git a/src/client/v2/indexer/indexer.ts b/src/client/v2/indexer/indexer.ts index c346bfec8..789015c30 100644 --- a/src/client/v2/indexer/indexer.ts +++ b/src/client/v2/indexer/indexer.ts @@ -18,7 +18,7 @@ export default class IndexerClient extends ServiceClient { constructor( token: string | IndexerTokenHeader | CustomTokenHeader, baseServer = 'http://127.0.0.1', - port = 8080, + port: string | number = 8080, headers = {} ) { super('X-Indexer-API-Token', token, baseServer, port, headers); diff --git a/src/client/v2/serviceClient.ts b/src/client/v2/serviceClient.ts index ab54ce5c4..9dd550205 100644 --- a/src/client/v2/serviceClient.ts +++ b/src/client/v2/serviceClient.ts @@ -32,7 +32,7 @@ export default abstract class ServiceClient { tokenHeaderIdentifier: TokenHeaderIdentifier, tokenHeaderOrStr: string | TokenHeader, baseServer: string, - port?: number, + port?: string | number, defaultHeaders: Record = {} ) { // Accept token header as string or object