@xchainjs/xchain-radix 0.1.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,20 @@ Radix module for XChainJS clients
14
14
  yarn add @xchainjs/xchain-radix
15
15
  ```
16
16
 
17
+ ## Create a new account
18
+
19
+ ```
20
+ import { generateMnemonic } from 'bip39'
21
+
22
+ const mnemonic = generateMnemonic()
23
+ const params: XChainClientParams = {
24
+ network: Network.Testnet,
25
+ phrase: mnemonic,
26
+ }
27
+ const client = new Client(params)
28
+ const address = await client.getAddressAsync()
29
+ ```
30
+
17
31
  ## Fund an account in testnet
18
32
 
19
33
  ```
package/lib/client.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { GatewayApiClient, TransactionSubmitResponse } from '@radixdlt/babylon-gateway-api-sdk';
3
3
  import { Curve, Intent, NotarizedTransaction, PrivateKey, PublicKey, TransactionHash } from '@radixdlt/radix-engine-toolkit';
4
- import { AssetInfo, Balance, BaseXChainClient, Fees, Network, PreparedTx, Tx, TxHistoryParams, TxParams, TxsPage, XChainClientParams } from '@xchainjs/xchain-client';
5
- import { Address, Asset } from '@xchainjs/xchain-util';
4
+ import { AssetInfo, BaseXChainClient, Fees, Network, PreparedTx, TxHistoryParams, XChainClientParams } from '@xchainjs/xchain-client';
5
+ import { Address } from '@xchainjs/xchain-util';
6
+ import { Balance, CompatibleAsset, Tx, TxParams, TxsPage } from './types/radix';
6
7
  /**
7
8
  * The main client for the Radix network which is then wrapped by the {Client} adapting it to have
8
9
  * a {BaseXChainClient} interface.
@@ -95,7 +96,7 @@ export default class Client extends BaseXChainClient {
95
96
  * @param {Asset[]} assets - Assets to retrieve the balance for (optional).
96
97
  * @returns {Promise<Balance[]>} An array containing the balance of the address.
97
98
  */
98
- getBalance(address: Address, assets?: Asset[]): Promise<Balance[]>;
99
+ getBalance(address: Address, assets?: CompatibleAsset[]): Promise<Balance[]>;
99
100
  /**
100
101
  * Get transaction history of a given address with pagination options.
101
102
  * @param {TxHistoryParams} params The options to get transaction history. (optional)
package/lib/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { GatewayApiClient } from '@radixdlt/babylon-gateway-api-sdk';
2
2
  import { NetworkId, PrivateKey, generateRandomNonce, RadixEngineToolkit, Convert, ManifestBuilder, decimal, address, bucket, enumeration, PublicKey, LTSRadixEngineToolkit, TransactionBuilder } from '@radixdlt/radix-engine-toolkit';
3
3
  import { Network, BaseXChainClient, singleFee, FeeType, TxType } from '@xchainjs/xchain-client';
4
4
  import { getSeed } from '@xchainjs/xchain-crypto';
5
- import { assetToBase, assetAmount, baseAmount } from '@xchainjs/xchain-util';
5
+ import { AssetType, assetToBase, assetAmount, baseAmount } from '@xchainjs/xchain-util';
6
6
  import { bech32m } from 'bech32';
7
7
  import BIP32Factory from 'bip32';
8
8
  import { derivePath } from 'ed25519-hd-key';
@@ -13909,13 +13909,13 @@ const XRD_DECIMAL = 18;
13909
13909
  const XrdAssetMainnet = {
13910
13910
  symbol: 'resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc',
13911
13911
  ticker: 'XRD',
13912
- synth: false,
13912
+ type: AssetType.NATIVE,
13913
13913
  chain: RadixChain,
13914
13914
  };
13915
13915
  const XrdAssetStokenet = {
13916
13916
  symbol: 'resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc',
13917
13917
  ticker: 'XRD',
13918
- synth: false,
13918
+ type: AssetType.NATIVE,
13919
13919
  chain: RadixChain,
13920
13920
  };
13921
13921
  const xrdRootDerivationPaths = {
@@ -14033,7 +14033,7 @@ class RadixSpecificClient {
14033
14033
  chain: RadixChain,
14034
14034
  symbol: item.resource_address,
14035
14035
  ticker: item.resource_address,
14036
- synth: false,
14036
+ type: AssetType.TOKEN,
14037
14037
  };
14038
14038
  const divisibility = divisibilities.get(item.resource_address) || 0;
14039
14039
  // We need to do this because item.amount can be either string or number
@@ -14533,7 +14533,7 @@ class Client extends BaseXChainClient {
14533
14533
  from.push({
14534
14534
  from: withdrawAccount,
14535
14535
  amount: baseAmount(withdrawAmount),
14536
- asset: { symbol: withdrawResource, ticker: withdrawResource, synth: false, chain: RadixChain },
14536
+ asset: { symbol: withdrawResource, ticker: withdrawResource, type: AssetType.TOKEN, chain: RadixChain },
14537
14537
  });
14538
14538
  }
14539
14539
  }
@@ -14544,7 +14544,7 @@ class Client extends BaseXChainClient {
14544
14544
  to.push({
14545
14545
  to: depositAccount,
14546
14546
  amount: baseAmount(depositAmount),
14547
- asset: { symbol: depositResource, ticker: depositResource, synth: false, chain: RadixChain },
14547
+ asset: { symbol: depositResource, ticker: depositResource, type: AssetType.TOKEN, chain: RadixChain },
14548
14548
  });
14549
14549
  }
14550
14550
  }
@@ -14554,7 +14554,7 @@ class Client extends BaseXChainClient {
14554
14554
  date: confirmed_at,
14555
14555
  type: TxType.Transfer,
14556
14556
  hash: intent_hash,
14557
- asset: { symbol: '', ticker: '', synth: false, chain: RadixChain },
14557
+ asset: { symbol: '', ticker: '', type: AssetType.TOKEN, chain: RadixChain },
14558
14558
  };
14559
14559
  return transaction;
14560
14560
  }
package/lib/index.js CHANGED
@@ -13921,13 +13921,13 @@ const XRD_DECIMAL = 18;
13921
13921
  const XrdAssetMainnet = {
13922
13922
  symbol: 'resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc',
13923
13923
  ticker: 'XRD',
13924
- synth: false,
13924
+ type: xchainUtil.AssetType.NATIVE,
13925
13925
  chain: RadixChain,
13926
13926
  };
13927
13927
  const XrdAssetStokenet = {
13928
13928
  symbol: 'resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc',
13929
13929
  ticker: 'XRD',
13930
- synth: false,
13930
+ type: xchainUtil.AssetType.NATIVE,
13931
13931
  chain: RadixChain,
13932
13932
  };
13933
13933
  const xrdRootDerivationPaths = {
@@ -14045,7 +14045,7 @@ class RadixSpecificClient {
14045
14045
  chain: RadixChain,
14046
14046
  symbol: item.resource_address,
14047
14047
  ticker: item.resource_address,
14048
- synth: false,
14048
+ type: xchainUtil.AssetType.TOKEN,
14049
14049
  };
14050
14050
  const divisibility = divisibilities.get(item.resource_address) || 0;
14051
14051
  // We need to do this because item.amount can be either string or number
@@ -14545,7 +14545,7 @@ class Client extends xchainClient.BaseXChainClient {
14545
14545
  from.push({
14546
14546
  from: withdrawAccount,
14547
14547
  amount: xchainUtil.baseAmount(withdrawAmount),
14548
- asset: { symbol: withdrawResource, ticker: withdrawResource, synth: false, chain: RadixChain },
14548
+ asset: { symbol: withdrawResource, ticker: withdrawResource, type: xchainUtil.AssetType.TOKEN, chain: RadixChain },
14549
14549
  });
14550
14550
  }
14551
14551
  }
@@ -14556,7 +14556,7 @@ class Client extends xchainClient.BaseXChainClient {
14556
14556
  to.push({
14557
14557
  to: depositAccount,
14558
14558
  amount: xchainUtil.baseAmount(depositAmount),
14559
- asset: { symbol: depositResource, ticker: depositResource, synth: false, chain: RadixChain },
14559
+ asset: { symbol: depositResource, ticker: depositResource, type: xchainUtil.AssetType.TOKEN, chain: RadixChain },
14560
14560
  });
14561
14561
  }
14562
14562
  }
@@ -14566,7 +14566,7 @@ class Client extends xchainClient.BaseXChainClient {
14566
14566
  date: confirmed_at,
14567
14567
  type: xchainClient.TxType.Transfer,
14568
14568
  hash: intent_hash,
14569
- asset: { symbol: '', ticker: '', synth: false, chain: RadixChain },
14569
+ asset: { symbol: '', ticker: '', type: xchainUtil.AssetType.TOKEN, chain: RadixChain },
14570
14570
  };
14571
14571
  return transaction;
14572
14572
  }
@@ -1,3 +1,6 @@
1
+ import { Balance as BaseBalance, Tx as BaseTx, TxFrom as BaseTxFrom, TxParams as BaseTxParams, TxTo as BaseTxTo, TxsPage as BaseTxsPage } from '@xchainjs/xchain-client';
2
+ import { Asset, TokenAsset } from '@xchainjs/xchain-util';
3
+ export type CompatibleAsset = Asset | TokenAsset;
1
4
  export type Transaction = {
2
5
  manifest: string;
3
6
  start_epoch_inclusive: number;
@@ -16,4 +19,39 @@ type TransactionFlag = {
16
19
  assume_all_signature_proofs: boolean;
17
20
  skip_epoch_check: boolean;
18
21
  };
22
+ /**
23
+ * Radix balance
24
+ */
25
+ export type Balance = BaseBalance & {
26
+ asset: CompatibleAsset;
27
+ };
28
+ /**
29
+ * Type definition for the sender of a Radix transaction.
30
+ */
31
+ export type TxFrom = BaseTxFrom & {
32
+ asset?: CompatibleAsset;
33
+ };
34
+ /**
35
+ * Type definition for the recipient of a Radix transaction.
36
+ */
37
+ export type TxTo = BaseTxTo & {
38
+ asset?: CompatibleAsset;
39
+ };
40
+ /**
41
+ * Type definition for a Radix transaction.
42
+ */
43
+ export type Tx = BaseTx & {
44
+ asset: CompatibleAsset;
45
+ from: TxFrom[];
46
+ to: TxTo[];
47
+ };
48
+ /**
49
+ * Type definition for a page of Radix transactions.
50
+ */
51
+ export type TxsPage = BaseTxsPage & {
52
+ txs: Tx[];
53
+ };
54
+ export type TxParams = BaseTxParams & {
55
+ asset?: CompatibleAsset;
56
+ };
19
57
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-radix",
3
- "version": "0.1.1",
3
+ "version": "1.0.1",
4
4
  "description": "Custom Radix client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "XRD",
@@ -44,6 +44,7 @@
44
44
  "@xchainjs/xchain-util": "workspace:*",
45
45
  "bech32": "^2.0.0",
46
46
  "bip32": "^4.0.0",
47
+ "bip39": "^3.1.0",
47
48
  "ed25519-hd-key": "^1.3.0"
48
49
  }
49
50
  }