@suilend/springsui-cli 1.0.12 → 1.0.14

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.
Files changed (66) hide show
  1. package/cli/src/bytecode.js +51 -55
  2. package/cli/src/index.js +165 -146
  3. package/package.json +1 -1
  4. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +8 -12
  5. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  6. package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
  7. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +2 -9
  8. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  9. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +5 -7
  10. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
  11. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +7 -11
  12. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  13. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +9 -16
  14. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  15. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -11
  16. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  17. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +73 -141
  18. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
  19. package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
  20. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +9 -15
  21. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  22. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +4 -6
  23. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
  24. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +9 -16
  25. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
  26. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +7 -11
  27. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
  28. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +15 -20
  29. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
  30. package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
  31. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +77 -159
  32. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
  33. package/sdk/src/_generated/_framework/reified.d.ts +2 -2
  34. package/sdk/src/_generated/_framework/reified.js +27 -40
  35. package/sdk/src/_generated/_framework/util.d.ts +4 -16
  36. package/sdk/src/_generated/_framework/util.js +26 -40
  37. package/sdk/src/_generated/_framework/vector.d.ts +1 -5
  38. package/sdk/src/_generated/_framework/vector.js +16 -21
  39. package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +2 -13
  40. package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
  41. package/sdk/src/_generated/liquid_staking/fees/functions.d.ts +19 -19
  42. package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
  43. package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +27 -51
  44. package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
  45. package/sdk/src/_generated/liquid_staking/index.js +6 -10
  46. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.d.ts +20 -20
  47. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
  48. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +144 -286
  49. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
  50. package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +44 -103
  51. package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
  52. package/sdk/src/_generated/liquid_staking/version/structs.d.ts +4 -6
  53. package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
  54. package/sdk/src/_generated/liquid_staking/weight/functions.d.ts +11 -11
  55. package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
  56. package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +61 -113
  57. package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
  58. package/sdk/src/client.d.ts +26 -36
  59. package/sdk/src/client.js +90 -126
  60. package/sdk/src/grpcAdapter.d.ts +50 -0
  61. package/sdk/src/grpcAdapter.js +75 -0
  62. package/sdk/src/index.d.ts +1 -0
  63. package/sdk/src/index.js +3 -18
  64. package/sdk/src/lib/index.js +1 -17
  65. package/sdk/src/lib/transactions.d.ts +1 -4
  66. package/sdk/src/lib/transactions.js +3 -8
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,21 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const assert_1 = __importDefault(require("assert"));
16
- const bcs_1 = require("@mysten/bcs");
17
- const move_bytecode_template_1 = require("@mysten/move-bytecode-template");
18
- const move_bytecode_template_2 = __importDefault(require("@mysten/move-bytecode-template"));
19
- const client_1 = require("@mysten/sui/client");
20
- const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
21
- const transactions_1 = require("@mysten/sui/transactions");
22
- const utils_1 = require("@mysten/sui/utils");
23
- const springsui_sdk_1 = require("@suilend/springsui-sdk");
10
+ import { bcs } from "@mysten/bcs";
11
+ import { update_constants, update_identifiers, } from "@mysten/move-bytecode-template";
12
+ import init from "@mysten/move-bytecode-template";
13
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
14
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
15
+ import { Transaction } from "@mysten/sui/transactions";
16
+ import { fromBase64, normalizeSuiAddress } from "@mysten/sui/utils";
17
+ import { LstClient } from "@suilend/springsui-sdk";
24
18
  // import url from "@mysten/move-bytecode-template/move_bytecode_template_bg.wasm?url";
25
- const keypair = ed25519_1.Ed25519Keypair.fromSecretKey((0, utils_1.fromBase64)(process.env.SUI_SECRET_KEY));
19
+ const keypair = Ed25519Keypair.fromSecretKey(fromBase64(process.env.SUI_SECRET_KEY));
26
20
  function generate_bytecode(lst_type, // eg K_SUI
27
21
  module_name, // eg ksui
28
22
  symbol, // eg sSUI
@@ -30,79 +24,81 @@ name, // eg Spring SUI
30
24
  description, // eg Spring SUI is a liquid staking protocol on Sui
31
25
  img_url) {
32
26
  const bytecode = Buffer.from("oRzrCwYAAAAKAQAMAgweAyonBFEIBVlMB6UBywEI8AJgBtADXQqtBAUMsgQoABABCwIGAhECEgITAAICAAEBBwEAAAIADAEAAQIDDAEAAQQEAgAFBQcAAAkAAQABDwUGAQACBwgJAQIDDAUBAQwDDQ0BAQwEDgoLAAUKAwQAAQQCBwQMAwICCAAHCAQAAQsCAQgAAQoCAQgFAQkAAQsBAQkAAQgABwkAAgoCCgIKAgsBAQgFBwgEAgsDAQkACwIBCQABBggEAQUBCwMBCAACCQAFDENvaW5NZXRhZGF0YQZPcHRpb24IVEVNUExBVEULVHJlYXN1cnlDYXAJVHhDb250ZXh0A1VybARjb2luD2NyZWF0ZV9jdXJyZW5jeQtkdW1teV9maWVsZARpbml0FW5ld191bnNhZmVfZnJvbV9ieXRlcwZvcHRpb24TcHVibGljX3NoYXJlX29iamVjdA9wdWJsaWNfdHJhbnNmZXIGc2VuZGVyBHNvbWUIdGVtcGxhdGUIdHJhbnNmZXIKdHhfY29udGV4dAN1cmwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAQkKAgUEVE1QTAoCDg1UZW1wbGF0ZSBDb2luCgIaGVRlbXBsYXRlIENvaW4gRGVzY3JpcHRpb24KAiEgaHR0cHM6Ly9leGFtcGxlLmNvbS90ZW1wbGF0ZS5wbmcAAgEIAQAAAAACEgsABwAHAQcCBwMHBBEGOAAKATgBDAILAS4RBTgCCwI4AwIA=", "base64");
33
- let updated = (0, move_bytecode_template_1.update_identifiers)(bytecode, {
27
+ let updated = update_identifiers(bytecode, {
34
28
  TEMPLATE: lst_type,
35
29
  template: module_name,
36
30
  });
37
- updated = (0, move_bytecode_template_1.update_constants)(updated, bcs_1.bcs.string().serialize(symbol).toBytes(), bcs_1.bcs.string().serialize("TMPL").toBytes(), "Vector(U8)" // type of the constant
38
- );
39
- updated = (0, move_bytecode_template_1.update_constants)(updated, bcs_1.bcs.string().serialize(name).toBytes(), // new value
40
- bcs_1.bcs.string().serialize("Template Coin").toBytes(), // current value
41
- "Vector(U8)" // type of the constant
42
- );
43
- updated = (0, move_bytecode_template_1.update_constants)(updated, bcs_1.bcs.string().serialize(description).toBytes(), // new value
44
- bcs_1.bcs.string().serialize("Template Coin Description").toBytes(), // current value
45
- "Vector(U8)" // type of the constant
46
- );
47
- updated = (0, move_bytecode_template_1.update_constants)(updated, bcs_1.bcs.string().serialize(img_url).toBytes(), // new value
48
- bcs_1.bcs.string().serialize("https://example.com/template.png").toBytes(), // current value
49
- "Vector(U8)" // type of the constant
50
- );
31
+ updated = update_constants(updated, bcs.string().serialize(symbol).toBytes(), bcs.string().serialize("TMPL").toBytes(), "Vector(U8)");
32
+ updated = update_constants(updated, bcs.string().serialize(name).toBytes(), // new value
33
+ bcs.string().serialize("Template Coin").toBytes(), // current value
34
+ "Vector(U8)");
35
+ updated = update_constants(updated, bcs.string().serialize(description).toBytes(), // new value
36
+ bcs.string().serialize("Template Coin Description").toBytes(), // current value
37
+ "Vector(U8)");
38
+ updated = update_constants(updated, bcs.string().serialize(img_url).toBytes(), // new value
39
+ bcs.string().serialize("https://example.com/template.png").toBytes(), // current value
40
+ "Vector(U8)");
51
41
  return updated;
52
42
  }
53
43
  function main() {
54
44
  return __awaiter(this, void 0, void 0, function* () {
55
- var _a;
56
- const client = new client_1.SuiClient({ url: "https://fullnode.mainnet.sui.io" });
45
+ var _a, _b, _c;
46
+ const client = new SuiGrpcClient({
47
+ baseUrl: "https://fullnode.mainnet.sui.io:443",
48
+ network: "mainnet",
49
+ });
57
50
  console.log("asdf");
58
- yield (0, move_bytecode_template_2.default)();
51
+ yield init();
59
52
  const bytecode = generate_bytecode("RIPLEYS_SUI", "ripleys_sui", "rSui", "Ripleys Staked Sui", "Ripleys Staked Sui is a liquid staking protocol on Sui", "https://example.com/ripleys.png");
60
53
  // Step 1: Create the coin
61
- const tx = new transactions_1.Transaction();
54
+ const tx = new Transaction();
62
55
  const [upgradeCap] = tx.publish({
63
56
  modules: [[...bytecode]],
64
- dependencies: [(0, utils_1.normalizeSuiAddress)("0x1"), (0, utils_1.normalizeSuiAddress)("0x2")],
57
+ dependencies: [normalizeSuiAddress("0x1"), normalizeSuiAddress("0x2")],
65
58
  });
66
59
  tx.transferObjects([upgradeCap], tx.pure.address(keypair.toSuiAddress()));
67
60
  const txResponse = yield client.signAndExecuteTransaction({
68
61
  transaction: tx,
69
62
  signer: keypair,
70
- options: {
71
- showEvents: true,
72
- showEffects: true,
73
- showObjectChanges: true,
63
+ include: {
64
+ events: true,
65
+ effects: true,
66
+ objectTypes: true,
74
67
  },
75
68
  });
76
69
  console.log(txResponse);
77
70
  // Step 2: Get the treasury Cap id from the transaction
78
- const treasuryCapObjectChange = (_a = txResponse.objectChanges) === null || _a === void 0 ? void 0 : _a.find((change) => change.type === "created" && change.objectType.includes("TreasuryCap"));
79
- (0, assert_1.default)((treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.type) === "created");
80
- const treasuryCapId = treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.objectId;
81
- const coinType = treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.objectType.split("<")[1].split(">")[0];
82
- console.log(coinType);
71
+ const txResult = (_a = txResponse.Transaction) !== null && _a !== void 0 ? _a : txResponse.FailedTransaction;
72
+ const treasuryCapObjectChange = txResult.effects.changedObjects.find((change) => change.idOperation === "Created" &&
73
+ txResult.objectTypes[change.objectId].includes("TreasuryCap"));
74
+ if (!treasuryCapObjectChange)
75
+ throw new Error("TreasuryCap not found");
76
+ const treasuryCapId = treasuryCapObjectChange.objectId;
83
77
  console.log(treasuryCapId);
78
+ const coinType = (_c = (_b = txResult.objectTypes[treasuryCapId]) === null || _b === void 0 ? void 0 : _b.split("<")[1]) === null || _c === void 0 ? void 0 : _c.split(">")[0];
79
+ console.log(coinType);
84
80
  // wait until the sui rpc recognizes the treasuryCapId
85
81
  while (true) {
86
- const object = yield client.getObject({ id: treasuryCapId });
87
- if (object.error) {
82
+ try {
83
+ yield client.getObject({ objectId: treasuryCapId });
84
+ break;
85
+ }
86
+ catch (_d) {
88
87
  console.log("waiting for sui rpc to recognize the treasuryCapId");
89
88
  yield new Promise((resolve) => setTimeout(resolve, 1000));
90
89
  }
91
- else {
92
- break;
93
- }
94
90
  }
95
91
  // Step 3: Create the lst
96
- const tx2 = new transactions_1.Transaction();
97
- const weightHookAdminCap = springsui_sdk_1.LstClient.createNewLst(tx2, treasuryCapId, coinType);
92
+ const tx2 = new Transaction();
93
+ const weightHookAdminCap = LstClient.createNewLst(tx2, treasuryCapId, coinType);
98
94
  tx2.transferObjects([tx2.object(weightHookAdminCap)], keypair.toSuiAddress());
99
95
  const txResponse2 = yield client.signAndExecuteTransaction({
100
96
  transaction: tx2,
101
97
  signer: keypair,
102
- options: {
103
- showEvents: true,
104
- showEffects: true,
105
- showObjectChanges: true,
98
+ include: {
99
+ events: true,
100
+ effects: true,
101
+ objectTypes: true,
106
102
  },
107
103
  });
108
104
  console.log(txResponse2);