@typus/typus-sdk 1.0.39 → 1.0.40

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.
@@ -0,0 +1,19 @@
1
+ export interface SponsoredTransaction {
2
+ txBytes: string;
3
+ txDigest: string;
4
+ signature: string;
5
+ expireAtTime: number;
6
+ expireAfterEpoch: number;
7
+ }
8
+ export type SponsoredTransactionStatus = "IN_FLIGHT" | "COMPLETE" | "INVALID";
9
+ export declare const sponsorRpcClient: (sponserRpcUrl: any) => {
10
+ gas_sponsorTransactionBlock: (txBytes: string, sender: string, gasBudget: number) => Promise<SponsoredTransaction>;
11
+ gas_getSponsoredTransactionBlockStatus: (txDigest: string) => Promise<SponsoredTransactionStatus>;
12
+ };
13
+ export interface SponsorRpc {
14
+ gas_sponsorTransactionBlock(txBytes: string, sender: string, gasBudget: number): SponsoredTransaction;
15
+ gas_getSponsoredTransactionBlockStatus(txDigest: string): SponsoredTransactionStatus;
16
+ }
17
+ export declare const sponsorTransactionBlock: (gaslessTxb: any, sponsor: any, provider: any, gasBudget: any, signerAddress: any) => Promise<[SponsoredTransaction, Uint8Array]>;
18
+ export declare const executeSponsorTransactionBlock: (provider: any, sponsoredResponse: any, senderSig: any) => Promise<void>;
19
+ export declare const sponsorTransactionE2E: (gaslessTxb: any, sponsor: any, provider: any, signer: any, gasBudget: any) => Promise<void>;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.sponsorTransactionE2E = exports.executeSponsorTransactionBlock = exports.sponsorTransactionBlock = exports.sponsorRpcClient = void 0;
40
+ var typed_rpc_1 = require("typed-rpc");
41
+ var sponsorRpcClient = function (sponserRpcUrl) { return (0, typed_rpc_1.rpcClient)(sponserRpcUrl); };
42
+ exports.sponsorRpcClient = sponsorRpcClient;
43
+ var sponsorTransactionBlock = function (gaslessTxb, sponsor, provider, gasBudget, signerAddress) { return __awaiter(void 0, void 0, void 0, function () {
44
+ var gaslessPayloadBytes, gaslessPayloadBase64, sponsoredResponse, sponsoredStatus, transactionBlock;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, gaslessTxb.build({ provider: provider, onlyTransactionKind: true })];
48
+ case 1:
49
+ gaslessPayloadBytes = _a.sent();
50
+ gaslessPayloadBase64 = btoa(gaslessPayloadBytes.reduce(function (data, byte) { return data + String.fromCharCode(byte); }, ""));
51
+ return [4 /*yield*/, sponsor.gas_sponsorTransactionBlock(gaslessPayloadBase64, signerAddress, gasBudget)];
52
+ case 2:
53
+ sponsoredResponse = _a.sent();
54
+ return [4 /*yield*/, sponsor.gas_getSponsoredTransactionBlockStatus(sponsoredResponse.txDigest)];
55
+ case 3:
56
+ sponsoredStatus = _a.sent();
57
+ console.log("Sponsorship Status:", sponsoredStatus);
58
+ transactionBlock = Uint8Array.from(atob(sponsoredResponse.txBytes), function (c) { return c.charCodeAt(0); });
59
+ return [2 /*return*/, [sponsoredResponse, transactionBlock]];
60
+ }
61
+ });
62
+ }); };
63
+ exports.sponsorTransactionBlock = sponsorTransactionBlock;
64
+ // // Sign the full transaction payload with the sender's key.
65
+ // const senderSig = await signer.signTransactionBlock({ transactionBlock });
66
+ var executeSponsorTransactionBlock = function (provider, sponsoredResponse, senderSig) { return __awaiter(void 0, void 0, void 0, function () {
67
+ var executeResponse;
68
+ var _a;
69
+ return __generator(this, function (_b) {
70
+ switch (_b.label) {
71
+ case 0: return [4 /*yield*/, provider.executeTransactionBlock({
72
+ transactionBlock: sponsoredResponse.txBytes,
73
+ signature: [senderSig.signature, sponsoredResponse.signature],
74
+ options: { showEffects: true },
75
+ requestType: "WaitForLocalExecution",
76
+ })];
77
+ case 1:
78
+ executeResponse = _b.sent();
79
+ console.log("Execution Status:", (_a = executeResponse.effects) === null || _a === void 0 ? void 0 : _a.status.status);
80
+ return [2 /*return*/];
81
+ }
82
+ });
83
+ }); };
84
+ exports.executeSponsorTransactionBlock = executeSponsorTransactionBlock;
85
+ var sponsorTransactionE2E = function (gaslessTxb, sponsor, provider, signer, gasBudget) { return __awaiter(void 0, void 0, void 0, function () {
86
+ var gaslessPayloadBytes, gaslessPayloadBase64, sponsoredResponse, _a, _b, _c, sponsoredStatus, transactionBlock, senderSig, executeResponse;
87
+ var _d;
88
+ return __generator(this, function (_e) {
89
+ switch (_e.label) {
90
+ case 0: return [4 /*yield*/, gaslessTxb.build({ provider: provider, onlyTransactionKind: true })];
91
+ case 1:
92
+ gaslessPayloadBytes = _e.sent();
93
+ gaslessPayloadBase64 = btoa(gaslessPayloadBytes.reduce(function (data, byte) { return data + String.fromCharCode(byte); }, ""));
94
+ _b = (_a = sponsor).gas_sponsorTransactionBlock;
95
+ _c = [gaslessPayloadBase64];
96
+ return [4 /*yield*/, signer.getAddress()];
97
+ case 2: return [4 /*yield*/, _b.apply(_a, _c.concat([_e.sent(), gasBudget]))];
98
+ case 3:
99
+ sponsoredResponse = _e.sent();
100
+ return [4 /*yield*/, sponsor.gas_getSponsoredTransactionBlockStatus(sponsoredResponse.txDigest)];
101
+ case 4:
102
+ sponsoredStatus = _e.sent();
103
+ console.log("Sponsorship Status:", sponsoredStatus);
104
+ transactionBlock = Uint8Array.from(atob(sponsoredResponse.txBytes), function (c) { return c.charCodeAt(0); });
105
+ return [4 /*yield*/, signer.signTransactionBlock({ transactionBlock: transactionBlock })];
106
+ case 5:
107
+ senderSig = _e.sent();
108
+ return [4 /*yield*/, provider.executeTransactionBlock({
109
+ transactionBlock: sponsoredResponse.txBytes,
110
+ signature: [senderSig.signature, sponsoredResponse.signature],
111
+ options: { showEffects: true },
112
+ requestType: "WaitForLocalExecution",
113
+ })];
114
+ case 6:
115
+ executeResponse = _e.sent();
116
+ console.log("Execution Status:", (_d = executeResponse.effects) === null || _d === void 0 ? void 0 : _d.status.status);
117
+ return [2 /*return*/];
118
+ }
119
+ });
120
+ }); };
121
+ exports.sponsorTransactionE2E = sponsorTransactionE2E;
@@ -254,7 +254,7 @@ function getNewBidTx(gasBudget, packageId, typeArguments, registry, index, price
254
254
  var tx, _a, coin;
255
255
  return __generator(this, function (_b) {
256
256
  tx = new sui_js_1.TransactionBlock();
257
- if (typeArguments[1] == sui_js_1.SUI_TYPE_ARG) {
257
+ if (typeArguments[1] == "0x2::sui::SUI" || typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
258
258
  _a = __read(tx.splitCoins(tx.gas, [tx.pure(premium_required)]), 1), coin = _a[0];
259
259
  tx.moveCall({
260
260
  target: "".concat(packageId, "::typus_dov_single::new_bid"),
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.0.39",
5
+ "version": "1.0.40",
6
6
  "dependencies": {
7
- "@mysten/sui.js": "0.32.0",
7
+ "@mysten/sui.js": "0.34.0",
8
8
  "@types/node": "^17.0.0",
9
9
  "bignumber.js": "^9.1.1",
10
10
  "bs58": "^4.0.1",