@deriverse/kit 1.0.18 → 1.0.20
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/index.js +16 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -262,6 +262,9 @@ class Engine {
|
|
|
262
262
|
let crncyTokenDec = 1;
|
|
263
263
|
let logs = [];
|
|
264
264
|
for (var log of data) {
|
|
265
|
+
if (log.startsWith("Program returned error")) {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
265
268
|
if (!log.startsWith("Program data: ")) {
|
|
266
269
|
continue;
|
|
267
270
|
}
|
|
@@ -642,7 +645,7 @@ class Engine {
|
|
|
642
645
|
commitment: this.commitment,
|
|
643
646
|
encoding: 'base64'
|
|
644
647
|
}).send();
|
|
645
|
-
if (infos == null) {
|
|
648
|
+
if (infos.value == null) {
|
|
646
649
|
throw new Error("Initialization failed: getMultipleAccountsInfo");
|
|
647
650
|
}
|
|
648
651
|
this.rootStateModel = structure_models_1.RootStateModel.fromBuffer(infos.value[0].data);
|
|
@@ -682,7 +685,7 @@ class Engine {
|
|
|
682
685
|
addToken(tokenAccount) {
|
|
683
686
|
return __awaiter(this, void 0, void 0, function* () {
|
|
684
687
|
const info = yield this.rpc.getAccountInfo(tokenAccount, { commitment: this.commitment, encoding: 'base64' }).send();
|
|
685
|
-
if (info == null) {
|
|
688
|
+
if (info.value == null) {
|
|
686
689
|
throw new Error("Add Token Failed: getAccountInfo");
|
|
687
690
|
}
|
|
688
691
|
const tokenStateModel = structure_models_1.TokenStateModel.fromBuffer(info.value.data);
|
|
@@ -697,7 +700,7 @@ class Engine {
|
|
|
697
700
|
addInstr(instrAccount) {
|
|
698
701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
699
702
|
const info = yield this.rpc.getAccountInfo(instrAccount, { commitment: this.commitment, encoding: 'base64' }).send();
|
|
700
|
-
if (info == null) {
|
|
703
|
+
if (info.value == null) {
|
|
701
704
|
throw new Error("Add Instrument Failed: getAccountInfo");
|
|
702
705
|
}
|
|
703
706
|
const instrAccountHeaderModel = structure_models_1.InstrAccountHeaderModel.fromBuffer(info.value.data);
|
|
@@ -736,7 +739,7 @@ class Engine {
|
|
|
736
739
|
updateCommunity() {
|
|
737
740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
738
741
|
const info = yield this.rpc.getAccountInfo(this.communityAccount, { commitment: this.commitment, encoding: 'base64' }).send();
|
|
739
|
-
if (info == null) {
|
|
742
|
+
if (info.value == null) {
|
|
740
743
|
throw new Error("Community Account: GetAccountInfo Failed");
|
|
741
744
|
}
|
|
742
745
|
this.updateCommunityFromBuffer(info.value.data);
|
|
@@ -748,7 +751,7 @@ class Engine {
|
|
|
748
751
|
updateRoot() {
|
|
749
752
|
return __awaiter(this, void 0, void 0, function* () {
|
|
750
753
|
const info = yield this.rpc.getAccountInfo(this.rootAccount, { commitment: this.commitment, encoding: 'base64' }).send();
|
|
751
|
-
if (info == null) {
|
|
754
|
+
if (info.value == null) {
|
|
752
755
|
throw new Error("Root Account: GetAccountInfo Failed");
|
|
753
756
|
}
|
|
754
757
|
this.updateRootFromBuffer(info.value.data);
|
|
@@ -1077,7 +1080,7 @@ class Engine {
|
|
|
1077
1080
|
tag: types_1.AccountType.INSTR
|
|
1078
1081
|
});
|
|
1079
1082
|
let info = yield this.rpc.getAccountInfo(instrAddress, { commitment: this.commitment, encoding: 'base64', dataSlice: { offset: structure_models_1.InstrAccountHeaderModel.OFFSET_ID, length: 4 } }).send();
|
|
1080
|
-
if (info == null) {
|
|
1083
|
+
if (info.value == null) {
|
|
1081
1084
|
return null;
|
|
1082
1085
|
}
|
|
1083
1086
|
else {
|
|
@@ -1187,7 +1190,7 @@ class Engine {
|
|
|
1187
1190
|
commitment: this.commitment,
|
|
1188
1191
|
encoding: 'base64'
|
|
1189
1192
|
}).send();
|
|
1190
|
-
if (info == null) {
|
|
1193
|
+
if (info.value == null) {
|
|
1191
1194
|
return false;
|
|
1192
1195
|
}
|
|
1193
1196
|
const clientPrimaryAccountHeaderModel = structure_models_1.ClientPrimaryAccountHeaderModel.fromBuffer(info.value.data);
|
|
@@ -1215,7 +1218,7 @@ class Engine {
|
|
|
1215
1218
|
commitment: this.commitment,
|
|
1216
1219
|
encoding: 'base64'
|
|
1217
1220
|
}).send();
|
|
1218
|
-
if (infos == null) {
|
|
1221
|
+
if (infos.value == null) {
|
|
1219
1222
|
throw new Error("GetClientData: GetAccountInfo failed");
|
|
1220
1223
|
}
|
|
1221
1224
|
const clientPrimaryAccountHeaderModel = structure_models_1.ClientPrimaryAccountHeaderModel.fromBuffer(infos.value[0].data);
|
|
@@ -2548,8 +2551,8 @@ class Engine {
|
|
|
2548
2551
|
const tokenProgramId = assetInfo.value.owner == TOKEN_2022_PROGRAM_ID ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID;
|
|
2549
2552
|
const crncyTokenId = yield this.getTokenId(args.crncyMint);
|
|
2550
2553
|
const id = yield this.getTokenId(args.assetMint);
|
|
2551
|
-
const
|
|
2552
|
-
const assetTokenId =
|
|
2554
|
+
const newAssetToken = id == null;
|
|
2555
|
+
const assetTokenId = newAssetToken ? this.rootStateModel.tokensCount : id;
|
|
2553
2556
|
if (!crncyTokenId) {
|
|
2554
2557
|
throw new Error("Currency mint not found");
|
|
2555
2558
|
}
|
|
@@ -2579,11 +2582,12 @@ class Engine {
|
|
|
2579
2582
|
let keys = [
|
|
2580
2583
|
{ address: this.signer, role: kit_1.AccountRole.READONLY_SIGNER },
|
|
2581
2584
|
{ address: this.rootAccount, role: kit_1.AccountRole.WRITABLE },
|
|
2582
|
-
{ address: yield this.getTokenAccount(args.assetMint), role:
|
|
2585
|
+
{ address: yield this.getTokenAccount(args.assetMint), role: newAssetToken ? kit_1.AccountRole.WRITABLE : kit_1.AccountRole.READONLY },
|
|
2583
2586
|
{ address: yield this.getTokenAccount(args.crncyMint), role: kit_1.AccountRole.READONLY },
|
|
2584
|
-
{ address:
|
|
2587
|
+
{ address: newAssetToken ? args.newProgramAccountAddress : this.tokens.get(assetTokenId).programAddress, role: newAssetToken ? kit_1.AccountRole.WRITABLE_SIGNER : kit_1.AccountRole.READONLY },
|
|
2585
2588
|
{ address: args.assetMint, role: kit_1.AccountRole.READONLY },
|
|
2586
2589
|
{ address: lutAddress, role: kit_1.AccountRole.WRITABLE },
|
|
2590
|
+
{ address: SYSTEM_PROGRAM_ID, role: kit_1.AccountRole.READONLY },
|
|
2587
2591
|
{ address: tokenProgramId, role: kit_1.AccountRole.READONLY },
|
|
2588
2592
|
{ address: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, role: kit_1.AccountRole.READONLY },
|
|
2589
2593
|
{ address: this.drvsAuthority, role: kit_1.AccountRole.READONLY },
|