@t2000/sdk 0.1.0 → 0.1.2

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
@@ -25,7 +25,7 @@ yarn add @t2000/sdk
25
25
  import { T2000 } from '@t2000/sdk';
26
26
 
27
27
  // Create or load a bank account
28
- const agent = await T2000.create({ passphrase: 'my-secret' });
28
+ const agent = await T2000.create({ pin: 'my-secret' });
29
29
 
30
30
  // Check balance
31
31
  const balance = await agent.balance();
@@ -52,7 +52,7 @@ Creates a new bank account or loads an existing one.
52
52
 
53
53
  ```typescript
54
54
  const agent = await T2000.create({
55
- passphrase: 'my-secret', // Required — encrypts/decrypts the key
55
+ pin: 'my-secret', // Required — encrypts/decrypts the key
56
56
  network: 'mainnet', // 'mainnet' | 'testnet' (default: 'mainnet')
57
57
  rpcUrl: 'https://...', // Custom RPC endpoint (optional)
58
58
  keyPath: '~/.t2000/wallet.key', // Custom key file path (optional)
@@ -159,7 +159,7 @@ Every transaction result includes a `gasMethod` field indicating which strategy
159
159
 
160
160
  | Environment Variable | Description | Default |
161
161
  |---------------------|-------------|---------|
162
- | `T2000_PASSPHRASE` | Bank account passphrase | — |
162
+ | `T2000_PIN` | Bank account PIN | — |
163
163
  | `T2000_NETWORK` | `mainnet` or `testnet` | `mainnet` |
164
164
  | `T2000_RPC_URL` | Custom Sui RPC URL | Sui public fullnode |
165
165
  | `T2000_KEY_PATH` | Path to encrypted key file | `~/.t2000/wallet.key` |
package/dist/index.cjs CHANGED
@@ -46,7 +46,7 @@ var DEFAULT_NETWORK = "mainnet";
46
46
  var DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
47
47
  var DEFAULT_KEY_PATH = "~/.t2000/wallet.key";
48
48
  var API_BASE_URL = process.env.T2000_API_URL ?? "https://api.t2000.ai";
49
- var CETUS_USDC_SUI_POOL = "0xb8d7d9e66a60c239e7a60110efcf8b555571a820a5c015ae1ce01bd5e9c4ac51";
49
+ var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
50
50
  var CETUS_GLOBAL_CONFIG = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
51
51
  var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
52
52
 
@@ -155,7 +155,7 @@ function decrypt(encrypted, passphrase) {
155
155
  try {
156
156
  return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
157
157
  } catch {
158
- throw new T2000Error("WALLET_LOCKED", "Invalid passphrase");
158
+ throw new T2000Error("WALLET_LOCKED", "Invalid PIN");
159
159
  }
160
160
  }
161
161
  function generateKeypair() {
@@ -997,12 +997,13 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
997
997
  this._address = getAddress(keypair);
998
998
  }
999
999
  static async create(options = {}) {
1000
- const { keyPath, passphrase, network = DEFAULT_NETWORK, rpcUrl, sponsored, name } = options;
1000
+ const { keyPath, pin, passphrase, network = DEFAULT_NETWORK, rpcUrl, sponsored, name } = options;
1001
+ const secret = pin ?? passphrase;
1001
1002
  const client = getSuiClient(rpcUrl);
1002
1003
  if (sponsored) {
1003
1004
  const keypair2 = generateKeypair();
1004
- if (passphrase) {
1005
- await saveKey(keypair2, passphrase, keyPath);
1005
+ if (secret) {
1006
+ await saveKey(keypair2, secret, keyPath);
1006
1007
  }
1007
1008
  return new _T2000(keypair2, client);
1008
1009
  }
@@ -1013,10 +1014,10 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
1013
1014
  "No wallet found. Run `t2000 init` to create one."
1014
1015
  );
1015
1016
  }
1016
- if (!passphrase) {
1017
- throw new T2000Error("WALLET_LOCKED", "Passphrase required to unlock wallet");
1017
+ if (!secret) {
1018
+ throw new T2000Error("WALLET_LOCKED", "PIN required to unlock wallet");
1018
1019
  }
1019
- const keypair = await loadKey(passphrase, keyPath);
1020
+ const keypair = await loadKey(secret, keyPath);
1020
1021
  return new _T2000(keypair, client);
1021
1022
  }
1022
1023
  static fromPrivateKey(privateKey, options = {}) {
@@ -1025,8 +1026,9 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
1025
1026
  return new _T2000(keypair, client);
1026
1027
  }
1027
1028
  static async init(options) {
1029
+ const secret = options.pin ?? options.passphrase ?? "";
1028
1030
  const keypair = generateKeypair();
1029
- await saveKey(keypair, options.passphrase, options.keyPath);
1031
+ await saveKey(keypair, secret, options.keyPath);
1030
1032
  const client = getSuiClient();
1031
1033
  const agent = new _T2000(keypair, client);
1032
1034
  const address = agent.address();