@typus/typus-perp-sdk 1.0.52 → 1.0.53-upgrade
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/dist/src/_dependencies/source/0x2/bag/structs.d.ts +61 -0
- package/dist/src/_dependencies/source/0x2/bag/structs.js +229 -0
- package/dist/src/_dependencies/source/0x2/balance/structs.d.ts +88 -0
- package/dist/src/_dependencies/source/0x2/balance/structs.js +386 -0
- package/dist/src/_dependencies/source/0x2/coin/structs.d.ts +460 -0
- package/dist/src/_dependencies/source/0x2/coin/structs.js +1247 -0
- package/dist/src/_dependencies/source/0x2/linked-table/structs.d.ts +153 -0
- package/dist/src/_dependencies/source/0x2/linked-table/structs.js +438 -0
- package/dist/src/_dependencies/source/0x2/sui/structs.d.ts +46 -0
- package/dist/src/_dependencies/source/0x2/sui/structs.js +222 -0
- package/dist/src/_dependencies/source/0x2/table/structs.d.ts +61 -0
- package/dist/src/_dependencies/source/0x2/table/structs.js +248 -0
- package/dist/src/_dependencies/source/0x2/table-vec/structs.d.ts +68 -0
- package/dist/src/_dependencies/source/0x2/table-vec/structs.js +274 -0
- package/dist/src/_dependencies/source/0x2/token/structs.d.ts +449 -0
- package/dist/src/_dependencies/source/0x2/token/structs.js +1095 -0
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.d.ts +370 -0
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.js +1091 -0
- package/dist/src/_dependencies/source/0x2/url/structs.d.ts +53 -0
- package/dist/src/_dependencies/source/0x2/url/structs.js +223 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.d.ts +489 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.js +1084 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.d.ts +147 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.js +456 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.d.ts +239 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.js +653 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.d.ts +405 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.js +899 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.d.ts +8 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.js +11 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.d.ts +2 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.js +102 -0
- package/dist/src/_dependencies/source/{0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277 → 0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a}/keyed-big-vector/structs.d.ts +70 -70
- package/dist/src/_dependencies/source/{0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277 → 0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a}/keyed-big-vector/structs.js +174 -174
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.d.ts +699 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.js +1459 -0
- package/dist/src/_dependencies/source/{0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277 → 0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a}/linked-object-table/structs.d.ts +62 -62
- package/dist/src/_dependencies/source/{0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277 → 0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a}/linked-object-table/structs.js +170 -170
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.d.ts +147 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.js +430 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.d.ts +1071 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.js +2261 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.d.ts +279 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.js +733 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.d.ts +328 -0
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.js +892 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.d.ts +88 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.js +263 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.d.ts +347 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.js +591 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.d.ts +73 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.js +258 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.d.ts +876 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.js +1721 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.d.ts +46 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.js +222 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.d.ts +3 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.js +6 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.d.ts +2 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.js +89 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.d.ts +155 -0
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.js +444 -0
- package/dist/src/_dependencies/source/{0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded → 0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274}/vault/structs.d.ts +84 -84
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.d.ts +446 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.js +844 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.d.ts +6 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.js +9 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.d.ts +2 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.js +69 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.d.ts +94 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.js +376 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.d.ts +454 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.js +881 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.d.ts +68 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.js +274 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.d.ts +1117 -0
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.js +2387 -0
- package/dist/src/fetch.d.ts +1 -1
- package/dist/src/fetch.js +1 -1
- package/dist/src/index.js +18 -18
- package/dist/src/typus_perp/admin/structs.d.ts +67 -5
- package/dist/src/typus_perp/admin/structs.js +155 -1
- package/dist/src/typus_perp/escrow/functions.js +1 -1
- package/dist/src/typus_perp/escrow/structs.d.ts +2 -2
- package/dist/src/typus_perp/escrow/structs.js +1 -1
- package/dist/src/typus_perp/lp-pool/structs.d.ts +28 -28
- package/dist/src/typus_perp/position/functions.js +1 -1
- package/dist/src/typus_perp/position/structs.d.ts +6 -6
- package/dist/src/typus_perp/symbol/structs.d.ts +1 -1
- package/dist/src/typus_perp/tlp/structs.d.ts +2 -2
- package/dist/src/typus_perp/trading/functions.js +1 -1
- package/dist/src/typus_perp/trading/structs.d.ts +32 -32
- package/dist/src/typus_perp/trading/structs.js +2 -2
- package/dist/src/typus_perp/treasury-caps/structs.d.ts +1 -1
- package/dist/src/typus_stake_pool/admin/functions.d.ts +25 -25
- package/dist/src/typus_stake_pool/admin/functions.js +66 -53
- package/dist/src/typus_stake_pool/admin/structs.d.ts +191 -191
- package/dist/src/typus_stake_pool/admin/structs.js +179 -179
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +50 -44
- package/dist/src/typus_stake_pool/stake-pool/functions.js +127 -88
- package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +202 -202
- package/dist/src/typus_stake_pool/stake-pool/structs.js +432 -432
- package/dist/src/user/history.js +6 -4
- package/dist/src/user/order.js +34 -34
- package/package.json +1 -1
- package/dist/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/index.d.ts +0 -8
- package/dist/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/index.js +0 -11
- package/dist/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/index.js +0 -6
- package/dist/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/index.js +0 -6
- /package/dist/src/_dependencies/source/{0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded → 0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274}/vault/structs.js +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
+
if (ar || !(i in from)) {
|
|
68
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
+
ar[i] = from[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
+
};
|
|
74
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
+
exports.SUI = void 0;
|
|
76
|
+
exports.isSUI = isSUI;
|
|
77
|
+
var reified_1 = require("../../../../_framework/reified");
|
|
78
|
+
var util_1 = require("../../../../_framework/util");
|
|
79
|
+
var index_1 = require("../index");
|
|
80
|
+
var bcs_1 = require("@mysten/sui/bcs");
|
|
81
|
+
var utils_1 = require("@mysten/sui/utils");
|
|
82
|
+
/* ============================== SUI =============================== */
|
|
83
|
+
function isSUI(type) {
|
|
84
|
+
type = (0, util_1.compressSuiType)(type);
|
|
85
|
+
return type === "".concat(index_1.PKG_V26, "::sui::SUI");
|
|
86
|
+
}
|
|
87
|
+
var SUI = /** @class */ (function () {
|
|
88
|
+
function SUI(typeArgs, fields) {
|
|
89
|
+
this.__StructClass = true;
|
|
90
|
+
this.$typeName = SUI.$typeName;
|
|
91
|
+
this.$isPhantom = SUI.$isPhantom;
|
|
92
|
+
this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([SUI.$typeName], __read(typeArgs), false));
|
|
93
|
+
this.$typeArgs = typeArgs;
|
|
94
|
+
this.dummyField = fields.dummyField;
|
|
95
|
+
}
|
|
96
|
+
SUI.reified = function () {
|
|
97
|
+
var _this = this;
|
|
98
|
+
return {
|
|
99
|
+
typeName: SUI.$typeName,
|
|
100
|
+
fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([SUI.$typeName], [], false)),
|
|
101
|
+
typeArgs: [],
|
|
102
|
+
isPhantom: SUI.$isPhantom,
|
|
103
|
+
reifiedTypeArgs: [],
|
|
104
|
+
fromFields: function (fields) { return SUI.fromFields(fields); },
|
|
105
|
+
fromFieldsWithTypes: function (item) { return SUI.fromFieldsWithTypes(item); },
|
|
106
|
+
fromBcs: function (data) { return SUI.fromBcs(data); },
|
|
107
|
+
bcs: SUI.bcs,
|
|
108
|
+
fromJSONField: function (field) { return SUI.fromJSONField(field); },
|
|
109
|
+
fromJSON: function (json) { return SUI.fromJSON(json); },
|
|
110
|
+
fromSuiParsedData: function (content) { return SUI.fromSuiParsedData(content); },
|
|
111
|
+
fromSuiObjectData: function (content) { return SUI.fromSuiObjectData(content); },
|
|
112
|
+
fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, SUI.fetch(client, id)];
|
|
114
|
+
}); }); },
|
|
115
|
+
new: function (fields) {
|
|
116
|
+
return new SUI([], fields);
|
|
117
|
+
},
|
|
118
|
+
kind: "StructClassReified",
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
Object.defineProperty(SUI, "r", {
|
|
122
|
+
get: function () {
|
|
123
|
+
return SUI.reified();
|
|
124
|
+
},
|
|
125
|
+
enumerable: false,
|
|
126
|
+
configurable: true
|
|
127
|
+
});
|
|
128
|
+
SUI.phantom = function () {
|
|
129
|
+
return (0, reified_1.phantom)(SUI.reified());
|
|
130
|
+
};
|
|
131
|
+
Object.defineProperty(SUI, "p", {
|
|
132
|
+
get: function () {
|
|
133
|
+
return SUI.phantom();
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(SUI, "bcs", {
|
|
139
|
+
get: function () {
|
|
140
|
+
return bcs_1.bcs.struct("SUI", {
|
|
141
|
+
dummy_field: bcs_1.bcs.bool(),
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: true
|
|
146
|
+
});
|
|
147
|
+
SUI.fromFields = function (fields) {
|
|
148
|
+
return SUI.reified().new({ dummyField: (0, reified_1.decodeFromFields)("bool", fields.dummy_field) });
|
|
149
|
+
};
|
|
150
|
+
SUI.fromFieldsWithTypes = function (item) {
|
|
151
|
+
if (!isSUI(item.type)) {
|
|
152
|
+
throw new Error("not a SUI type");
|
|
153
|
+
}
|
|
154
|
+
return SUI.reified().new({ dummyField: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.dummy_field) });
|
|
155
|
+
};
|
|
156
|
+
SUI.fromBcs = function (data) {
|
|
157
|
+
return SUI.fromFields(SUI.bcs.parse(data));
|
|
158
|
+
};
|
|
159
|
+
SUI.prototype.toJSONField = function () {
|
|
160
|
+
return {
|
|
161
|
+
dummyField: this.dummyField,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
SUI.prototype.toJSON = function () {
|
|
165
|
+
return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
166
|
+
};
|
|
167
|
+
SUI.fromJSONField = function (field) {
|
|
168
|
+
return SUI.reified().new({ dummyField: (0, reified_1.decodeFromJSONField)("bool", field.dummyField) });
|
|
169
|
+
};
|
|
170
|
+
SUI.fromJSON = function (json) {
|
|
171
|
+
if (json.$typeName !== SUI.$typeName) {
|
|
172
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
173
|
+
}
|
|
174
|
+
return SUI.fromJSONField(json);
|
|
175
|
+
};
|
|
176
|
+
SUI.fromSuiParsedData = function (content) {
|
|
177
|
+
if (content.dataType !== "moveObject") {
|
|
178
|
+
throw new Error("not an object");
|
|
179
|
+
}
|
|
180
|
+
if (!isSUI(content.type)) {
|
|
181
|
+
throw new Error("object at ".concat(content.fields.id, " is not a SUI object"));
|
|
182
|
+
}
|
|
183
|
+
return SUI.fromFieldsWithTypes(content);
|
|
184
|
+
};
|
|
185
|
+
SUI.fromSuiObjectData = function (data) {
|
|
186
|
+
if (data.bcs) {
|
|
187
|
+
if (data.bcs.dataType !== "moveObject" || !isSUI(data.bcs.type)) {
|
|
188
|
+
throw new Error("object at is not a SUI object");
|
|
189
|
+
}
|
|
190
|
+
return SUI.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
191
|
+
}
|
|
192
|
+
if (data.content) {
|
|
193
|
+
return SUI.fromSuiParsedData(data.content);
|
|
194
|
+
}
|
|
195
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
196
|
+
};
|
|
197
|
+
SUI.fetch = function (client, id) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var res;
|
|
200
|
+
var _a, _b;
|
|
201
|
+
return __generator(this, function (_c) {
|
|
202
|
+
switch (_c.label) {
|
|
203
|
+
case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
|
|
204
|
+
case 1:
|
|
205
|
+
res = _c.sent();
|
|
206
|
+
if (res.error) {
|
|
207
|
+
throw new Error("error fetching SUI object at id ".concat(id, ": ").concat(res.error.code));
|
|
208
|
+
}
|
|
209
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isSUI(res.data.bcs.type)) {
|
|
210
|
+
throw new Error("object at id ".concat(id, " is not a SUI object"));
|
|
211
|
+
}
|
|
212
|
+
return [2 /*return*/, SUI.fromSuiObjectData(res.data)];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
SUI.$typeName = "".concat(index_1.PKG_V26, "::sui::SUI");
|
|
218
|
+
SUI.$numTypeParams = 0;
|
|
219
|
+
SUI.$isPhantom = [];
|
|
220
|
+
return SUI;
|
|
221
|
+
}());
|
|
222
|
+
exports.SUI = SUI;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../../../_framework/reified";
|
|
2
|
+
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
|
+
import { PKG_V26 } from "../index";
|
|
4
|
+
import { UID } from "../object/structs";
|
|
5
|
+
import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
|
|
6
|
+
export declare function isTable(type: string): boolean;
|
|
7
|
+
export interface TableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> {
|
|
8
|
+
id: ToField<UID>;
|
|
9
|
+
size: ToField<"u64">;
|
|
10
|
+
}
|
|
11
|
+
export type TableReified<K extends PhantomTypeArgument, V extends PhantomTypeArgument> = Reified<Table<K, V>, TableFields<K, V>>;
|
|
12
|
+
export declare class Table<K extends PhantomTypeArgument, V extends PhantomTypeArgument> implements StructClass {
|
|
13
|
+
__StructClass: true;
|
|
14
|
+
static readonly $typeName = "0x2::table::Table";
|
|
15
|
+
static readonly $numTypeParams = 2;
|
|
16
|
+
static readonly $isPhantom: readonly [true, true];
|
|
17
|
+
readonly $typeName = "0x2::table::Table";
|
|
18
|
+
readonly $fullTypeName: `${typeof PKG_V26}::table::Table<${PhantomToTypeStr<K>}, ${PhantomToTypeStr<V>}>`;
|
|
19
|
+
readonly $typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>];
|
|
20
|
+
readonly $isPhantom: readonly [true, true];
|
|
21
|
+
readonly id: ToField<UID>;
|
|
22
|
+
readonly size: ToField<"u64">;
|
|
23
|
+
private constructor();
|
|
24
|
+
static reified<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): TableReified<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
25
|
+
static get r(): typeof Table.reified;
|
|
26
|
+
static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
|
|
27
|
+
static get p(): typeof Table.phantom;
|
|
28
|
+
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
29
|
+
id: {
|
|
30
|
+
id: {
|
|
31
|
+
bytes: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
size: string;
|
|
35
|
+
}, {
|
|
36
|
+
id: {
|
|
37
|
+
id: {
|
|
38
|
+
bytes: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
size: string | number | bigint;
|
|
42
|
+
}>;
|
|
43
|
+
static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], fields: Record<string, any>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
44
|
+
static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
45
|
+
static fromBcs<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: Uint8Array): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
46
|
+
toJSONField(): {
|
|
47
|
+
id: string;
|
|
48
|
+
size: string;
|
|
49
|
+
};
|
|
50
|
+
toJSON(): {
|
|
51
|
+
id: string;
|
|
52
|
+
size: string;
|
|
53
|
+
$typeName: string;
|
|
54
|
+
$typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>];
|
|
55
|
+
};
|
|
56
|
+
static fromJSONField<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], field: any): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
57
|
+
static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], json: Record<string, any>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
58
|
+
static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], content: SuiParsedData): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
59
|
+
static fromSuiObjectData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: SuiObjectData): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
60
|
+
static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArgs: [K, V], id: string): Promise<Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
+
if (ar || !(i in from)) {
|
|
68
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
+
ar[i] = from[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
+
};
|
|
74
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
+
exports.Table = void 0;
|
|
76
|
+
exports.isTable = isTable;
|
|
77
|
+
var reified_1 = require("../../../../_framework/reified");
|
|
78
|
+
var util_1 = require("../../../../_framework/util");
|
|
79
|
+
var index_1 = require("../index");
|
|
80
|
+
var structs_1 = require("../object/structs");
|
|
81
|
+
var bcs_1 = require("@mysten/sui/bcs");
|
|
82
|
+
var utils_1 = require("@mysten/sui/utils");
|
|
83
|
+
/* ============================== Table =============================== */
|
|
84
|
+
function isTable(type) {
|
|
85
|
+
type = (0, util_1.compressSuiType)(type);
|
|
86
|
+
return type.startsWith("".concat(index_1.PKG_V26, "::table::Table") + "<");
|
|
87
|
+
}
|
|
88
|
+
var Table = /** @class */ (function () {
|
|
89
|
+
function Table(typeArgs, fields) {
|
|
90
|
+
this.__StructClass = true;
|
|
91
|
+
this.$typeName = Table.$typeName;
|
|
92
|
+
this.$isPhantom = Table.$isPhantom;
|
|
93
|
+
this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([Table.$typeName], __read(typeArgs), false));
|
|
94
|
+
this.$typeArgs = typeArgs;
|
|
95
|
+
this.id = fields.id;
|
|
96
|
+
this.size = fields.size;
|
|
97
|
+
}
|
|
98
|
+
Table.reified = function (K, V) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
return {
|
|
101
|
+
typeName: Table.$typeName,
|
|
102
|
+
fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([Table.$typeName], [(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)], false)),
|
|
103
|
+
typeArgs: [(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)],
|
|
104
|
+
isPhantom: Table.$isPhantom,
|
|
105
|
+
reifiedTypeArgs: [K, V],
|
|
106
|
+
fromFields: function (fields) { return Table.fromFields([K, V], fields); },
|
|
107
|
+
fromFieldsWithTypes: function (item) { return Table.fromFieldsWithTypes([K, V], item); },
|
|
108
|
+
fromBcs: function (data) { return Table.fromBcs([K, V], data); },
|
|
109
|
+
bcs: Table.bcs,
|
|
110
|
+
fromJSONField: function (field) { return Table.fromJSONField([K, V], field); },
|
|
111
|
+
fromJSON: function (json) { return Table.fromJSON([K, V], json); },
|
|
112
|
+
fromSuiParsedData: function (content) { return Table.fromSuiParsedData([K, V], content); },
|
|
113
|
+
fromSuiObjectData: function (content) { return Table.fromSuiObjectData([K, V], content); },
|
|
114
|
+
fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
115
|
+
return [2 /*return*/, Table.fetch(client, [K, V], id)];
|
|
116
|
+
}); }); },
|
|
117
|
+
new: function (fields) {
|
|
118
|
+
return new Table([(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)], fields);
|
|
119
|
+
},
|
|
120
|
+
kind: "StructClassReified",
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
Object.defineProperty(Table, "r", {
|
|
124
|
+
get: function () {
|
|
125
|
+
return Table.reified;
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Table.phantom = function (K, V) {
|
|
131
|
+
return (0, reified_1.phantom)(Table.reified(K, V));
|
|
132
|
+
};
|
|
133
|
+
Object.defineProperty(Table, "p", {
|
|
134
|
+
get: function () {
|
|
135
|
+
return Table.phantom;
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(Table, "bcs", {
|
|
141
|
+
get: function () {
|
|
142
|
+
return bcs_1.bcs.struct("Table", {
|
|
143
|
+
id: structs_1.UID.bcs,
|
|
144
|
+
size: bcs_1.bcs.u64(),
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
enumerable: false,
|
|
148
|
+
configurable: true
|
|
149
|
+
});
|
|
150
|
+
Table.fromFields = function (typeArgs, fields) {
|
|
151
|
+
return Table.reified(typeArgs[0], typeArgs[1]).new({
|
|
152
|
+
id: (0, reified_1.decodeFromFields)(structs_1.UID.reified(), fields.id),
|
|
153
|
+
size: (0, reified_1.decodeFromFields)("u64", fields.size),
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
Table.fromFieldsWithTypes = function (typeArgs, item) {
|
|
157
|
+
if (!isTable(item.type)) {
|
|
158
|
+
throw new Error("not a Table type");
|
|
159
|
+
}
|
|
160
|
+
(0, reified_1.assertFieldsWithTypesArgsMatch)(item, typeArgs);
|
|
161
|
+
return Table.reified(typeArgs[0], typeArgs[1]).new({
|
|
162
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.UID.reified(), item.fields.id),
|
|
163
|
+
size: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.size),
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
Table.fromBcs = function (typeArgs, data) {
|
|
167
|
+
return Table.fromFields(typeArgs, Table.bcs.parse(data));
|
|
168
|
+
};
|
|
169
|
+
Table.prototype.toJSONField = function () {
|
|
170
|
+
return {
|
|
171
|
+
id: this.id,
|
|
172
|
+
size: this.size.toString(),
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
Table.prototype.toJSON = function () {
|
|
176
|
+
return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
177
|
+
};
|
|
178
|
+
Table.fromJSONField = function (typeArgs, field) {
|
|
179
|
+
return Table.reified(typeArgs[0], typeArgs[1]).new({
|
|
180
|
+
id: (0, reified_1.decodeFromJSONField)(structs_1.UID.reified(), field.id),
|
|
181
|
+
size: (0, reified_1.decodeFromJSONField)("u64", field.size),
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
Table.fromJSON = function (typeArgs, json) {
|
|
185
|
+
if (json.$typeName !== Table.$typeName) {
|
|
186
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
187
|
+
}
|
|
188
|
+
(0, reified_1.assertReifiedTypeArgsMatch)(util_1.composeSuiType.apply(void 0, __spreadArray([Table.$typeName], __read(typeArgs.map(reified_1.extractType)), false)), json.$typeArgs, typeArgs);
|
|
189
|
+
return Table.fromJSONField(typeArgs, json);
|
|
190
|
+
};
|
|
191
|
+
Table.fromSuiParsedData = function (typeArgs, content) {
|
|
192
|
+
if (content.dataType !== "moveObject") {
|
|
193
|
+
throw new Error("not an object");
|
|
194
|
+
}
|
|
195
|
+
if (!isTable(content.type)) {
|
|
196
|
+
throw new Error("object at ".concat(content.fields.id, " is not a Table object"));
|
|
197
|
+
}
|
|
198
|
+
return Table.fromFieldsWithTypes(typeArgs, content);
|
|
199
|
+
};
|
|
200
|
+
Table.fromSuiObjectData = function (typeArgs, data) {
|
|
201
|
+
if (data.bcs) {
|
|
202
|
+
if (data.bcs.dataType !== "moveObject" || !isTable(data.bcs.type)) {
|
|
203
|
+
throw new Error("object at is not a Table object");
|
|
204
|
+
}
|
|
205
|
+
var gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
|
|
206
|
+
if (gotTypeArgs.length !== 2) {
|
|
207
|
+
throw new Error("type argument mismatch: expected 2 type arguments but got ".concat(gotTypeArgs.length));
|
|
208
|
+
}
|
|
209
|
+
for (var i = 0; i < 2; i++) {
|
|
210
|
+
var gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[i]);
|
|
211
|
+
var expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArgs[i]));
|
|
212
|
+
if (gotTypeArg !== expectedTypeArg) {
|
|
213
|
+
throw new Error("type argument mismatch at position ".concat(i, ": expected '").concat(expectedTypeArg, "' but got '").concat(gotTypeArg, "'"));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return Table.fromBcs(typeArgs, (0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
217
|
+
}
|
|
218
|
+
if (data.content) {
|
|
219
|
+
return Table.fromSuiParsedData(typeArgs, data.content);
|
|
220
|
+
}
|
|
221
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
222
|
+
};
|
|
223
|
+
Table.fetch = function (client, typeArgs, id) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var res;
|
|
226
|
+
var _a, _b;
|
|
227
|
+
return __generator(this, function (_c) {
|
|
228
|
+
switch (_c.label) {
|
|
229
|
+
case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
|
|
230
|
+
case 1:
|
|
231
|
+
res = _c.sent();
|
|
232
|
+
if (res.error) {
|
|
233
|
+
throw new Error("error fetching Table object at id ".concat(id, ": ").concat(res.error.code));
|
|
234
|
+
}
|
|
235
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isTable(res.data.bcs.type)) {
|
|
236
|
+
throw new Error("object at id ".concat(id, " is not a Table object"));
|
|
237
|
+
}
|
|
238
|
+
return [2 /*return*/, Table.fromSuiObjectData(typeArgs, res.data)];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
Table.$typeName = "".concat(index_1.PKG_V26, "::table::Table");
|
|
244
|
+
Table.$numTypeParams = 2;
|
|
245
|
+
Table.$isPhantom = [true, true];
|
|
246
|
+
return Table;
|
|
247
|
+
}());
|
|
248
|
+
exports.Table = Table;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as reified from "../../../../_framework/reified";
|
|
2
|
+
import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../../../_framework/reified";
|
|
3
|
+
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
4
|
+
import { PKG_V26 } from "../index";
|
|
5
|
+
import { Table } from "../table/structs";
|
|
6
|
+
import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
|
|
7
|
+
export declare function isTableVec(type: string): boolean;
|
|
8
|
+
export interface TableVecFields<Element extends PhantomTypeArgument> {
|
|
9
|
+
contents: ToField<Table<"u64", Element>>;
|
|
10
|
+
}
|
|
11
|
+
export type TableVecReified<Element extends PhantomTypeArgument> = Reified<TableVec<Element>, TableVecFields<Element>>;
|
|
12
|
+
export declare class TableVec<Element extends PhantomTypeArgument> implements StructClass {
|
|
13
|
+
__StructClass: true;
|
|
14
|
+
static readonly $typeName = "0x2::table_vec::TableVec";
|
|
15
|
+
static readonly $numTypeParams = 1;
|
|
16
|
+
static readonly $isPhantom: readonly [true];
|
|
17
|
+
readonly $typeName = "0x2::table_vec::TableVec";
|
|
18
|
+
readonly $fullTypeName: `${typeof PKG_V26}::table_vec::TableVec<${PhantomToTypeStr<Element>}>`;
|
|
19
|
+
readonly $typeArgs: [PhantomToTypeStr<Element>];
|
|
20
|
+
readonly $isPhantom: readonly [true];
|
|
21
|
+
readonly contents: ToField<Table<"u64", Element>>;
|
|
22
|
+
private constructor();
|
|
23
|
+
static reified<Element extends PhantomReified<PhantomTypeArgument>>(Element: Element): TableVecReified<ToPhantomTypeArgument<Element>>;
|
|
24
|
+
static get r(): typeof TableVec.reified;
|
|
25
|
+
static phantom<Element extends PhantomReified<PhantomTypeArgument>>(Element: Element): PhantomReified<ToTypeStr<TableVec<ToPhantomTypeArgument<Element>>>>;
|
|
26
|
+
static get p(): typeof TableVec.phantom;
|
|
27
|
+
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
28
|
+
contents: {
|
|
29
|
+
id: {
|
|
30
|
+
id: {
|
|
31
|
+
bytes: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
size: string;
|
|
35
|
+
};
|
|
36
|
+
}, {
|
|
37
|
+
contents: {
|
|
38
|
+
id: {
|
|
39
|
+
id: {
|
|
40
|
+
bytes: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
size: string | number | bigint;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
static fromFields<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, fields: Record<string, any>): TableVec<ToPhantomTypeArgument<Element>>;
|
|
47
|
+
static fromFieldsWithTypes<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, item: FieldsWithTypes): TableVec<ToPhantomTypeArgument<Element>>;
|
|
48
|
+
static fromBcs<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, data: Uint8Array): TableVec<ToPhantomTypeArgument<Element>>;
|
|
49
|
+
toJSONField(): {
|
|
50
|
+
contents: {
|
|
51
|
+
id: string;
|
|
52
|
+
size: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
toJSON(): {
|
|
56
|
+
contents: {
|
|
57
|
+
id: string;
|
|
58
|
+
size: string;
|
|
59
|
+
};
|
|
60
|
+
$typeName: string;
|
|
61
|
+
$typeArgs: [reified.PhantomToTypeStr<Element>];
|
|
62
|
+
};
|
|
63
|
+
static fromJSONField<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, field: any): TableVec<ToPhantomTypeArgument<Element>>;
|
|
64
|
+
static fromJSON<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, json: Record<string, any>): TableVec<ToPhantomTypeArgument<Element>>;
|
|
65
|
+
static fromSuiParsedData<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, content: SuiParsedData): TableVec<ToPhantomTypeArgument<Element>>;
|
|
66
|
+
static fromSuiObjectData<Element extends PhantomReified<PhantomTypeArgument>>(typeArg: Element, data: SuiObjectData): TableVec<ToPhantomTypeArgument<Element>>;
|
|
67
|
+
static fetch<Element extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArg: Element, id: string): Promise<TableVec<ToPhantomTypeArgument<Element>>>;
|
|
68
|
+
}
|