@suilend/springsui-cli 1.0.13 → 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.
- package/cli/src/bytecode.js +48 -48
- package/cli/src/index.js +165 -146
- package/package.json +1 -1
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +2 -7
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +3 -3
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +6 -6
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +44 -58
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
- package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +6 -6
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +3 -3
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +6 -6
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
- package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +52 -60
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
- package/sdk/src/_generated/_framework/reified.d.ts +2 -2
- package/sdk/src/_generated/_framework/reified.js +27 -40
- package/sdk/src/_generated/_framework/util.d.ts +4 -16
- package/sdk/src/_generated/_framework/util.js +26 -40
- package/sdk/src/_generated/_framework/vector.d.ts +1 -12
- package/sdk/src/_generated/_framework/vector.js +16 -21
- package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +2 -9
- package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
- package/sdk/src/_generated/liquid_staking/fees/functions.d.ts +19 -19
- package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
- package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +19 -19
- package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
- package/sdk/src/_generated/liquid_staking/index.js +6 -10
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.d.ts +20 -20
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +90 -184
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
- package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +31 -143
- package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
- package/sdk/src/_generated/liquid_staking/version/structs.d.ts +3 -3
- package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
- package/sdk/src/_generated/liquid_staking/weight/functions.d.ts +11 -11
- package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
- package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +36 -36
- package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
- package/sdk/src/client.d.ts +26 -36
- package/sdk/src/client.js +90 -126
- package/sdk/src/grpcAdapter.d.ts +50 -0
- package/sdk/src/grpcAdapter.js +75 -0
- package/sdk/src/index.d.ts +1 -0
- package/sdk/src/index.js +3 -18
- package/sdk/src/lib/index.js +1 -17
- package/sdk/src/lib/transactions.d.ts +1 -4
- package/sdk/src/lib/transactions.js +3 -8
package/cli/src/bytecode.js
CHANGED
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 =
|
|
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,75 +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 =
|
|
27
|
+
let updated = update_identifiers(bytecode, {
|
|
34
28
|
TEMPLATE: lst_type,
|
|
35
29
|
template: module_name,
|
|
36
30
|
});
|
|
37
|
-
updated =
|
|
38
|
-
updated =
|
|
39
|
-
|
|
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
|
|
40
34
|
"Vector(U8)");
|
|
41
|
-
updated =
|
|
42
|
-
|
|
35
|
+
updated = update_constants(updated, bcs.string().serialize(description).toBytes(), // new value
|
|
36
|
+
bcs.string().serialize("Template Coin Description").toBytes(), // current value
|
|
43
37
|
"Vector(U8)");
|
|
44
|
-
updated =
|
|
45
|
-
|
|
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
|
|
46
40
|
"Vector(U8)");
|
|
47
41
|
return updated;
|
|
48
42
|
}
|
|
49
43
|
function main() {
|
|
50
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
var _a;
|
|
52
|
-
const client = new
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const client = new SuiGrpcClient({
|
|
47
|
+
baseUrl: "https://fullnode.mainnet.sui.io:443",
|
|
48
|
+
network: "mainnet",
|
|
49
|
+
});
|
|
53
50
|
console.log("asdf");
|
|
54
|
-
yield (
|
|
51
|
+
yield init();
|
|
55
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");
|
|
56
53
|
// Step 1: Create the coin
|
|
57
|
-
const tx = new
|
|
54
|
+
const tx = new Transaction();
|
|
58
55
|
const [upgradeCap] = tx.publish({
|
|
59
56
|
modules: [[...bytecode]],
|
|
60
|
-
dependencies: [
|
|
57
|
+
dependencies: [normalizeSuiAddress("0x1"), normalizeSuiAddress("0x2")],
|
|
61
58
|
});
|
|
62
59
|
tx.transferObjects([upgradeCap], tx.pure.address(keypair.toSuiAddress()));
|
|
63
60
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
64
61
|
transaction: tx,
|
|
65
62
|
signer: keypair,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
include: {
|
|
64
|
+
events: true,
|
|
65
|
+
effects: true,
|
|
66
|
+
objectTypes: true,
|
|
70
67
|
},
|
|
71
68
|
});
|
|
72
69
|
console.log(txResponse);
|
|
73
70
|
// Step 2: Get the treasury Cap id from the transaction
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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;
|
|
79
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);
|
|
80
80
|
// wait until the sui rpc recognizes the treasuryCapId
|
|
81
81
|
while (true) {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
try {
|
|
83
|
+
yield client.getObject({ objectId: treasuryCapId });
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
catch (_d) {
|
|
84
87
|
console.log("waiting for sui rpc to recognize the treasuryCapId");
|
|
85
88
|
yield new Promise((resolve) => setTimeout(resolve, 1000));
|
|
86
89
|
}
|
|
87
|
-
else {
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
90
|
}
|
|
91
91
|
// Step 3: Create the lst
|
|
92
|
-
const tx2 = new
|
|
93
|
-
const weightHookAdminCap =
|
|
92
|
+
const tx2 = new Transaction();
|
|
93
|
+
const weightHookAdminCap = LstClient.createNewLst(tx2, treasuryCapId, coinType);
|
|
94
94
|
tx2.transferObjects([tx2.object(weightHookAdminCap)], keypair.toSuiAddress());
|
|
95
95
|
const txResponse2 = yield client.signAndExecuteTransaction({
|
|
96
96
|
transaction: tx2,
|
|
97
97
|
signer: keypair,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
include: {
|
|
99
|
+
events: true,
|
|
100
|
+
effects: true,
|
|
101
|
+
objectTypes: true,
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
104
|
console.log(txResponse2);
|