@algorandfoundation/algokit-utils 9.0.2-beta.1 → 9.1.0-beta.1
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/package.json +1 -1
- package/types/algorand-client.d.ts +13 -2
- package/types/algorand-client.js +17 -1
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +17 -1
- package/types/algorand-client.mjs.map +1 -1
- package/types/app-client.js +32 -32
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +32 -32
- package/types/app-client.mjs.map +1 -1
- package/types/composer.d.ts +21 -1
- package/types/composer.js +58 -15
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +58 -15
- package/types/composer.mjs.map +1 -1
- package/types/instance-of.d.ts +6 -0
- package/types/instance-of.js +3 -0
- package/types/instance-of.js.map +1 -0
- package/types/instance-of.mjs +2 -0
- package/types/instance-of.mjs.map +1 -0
package/types/app-client.mjs
CHANGED
|
@@ -107,11 +107,29 @@ class AppClient {
|
|
|
107
107
|
* })
|
|
108
108
|
*/
|
|
109
109
|
constructor(params) {
|
|
110
|
+
/** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */
|
|
111
|
+
this.handleCallErrors = async (e) => {
|
|
112
|
+
// Only handle errors for this app.
|
|
113
|
+
const appIdString = `app=${this._appId.toString()}`;
|
|
114
|
+
if (!e.message.includes(appIdString))
|
|
115
|
+
return e;
|
|
116
|
+
const logicError = await this.exposeLogicError(e);
|
|
117
|
+
if (logicError instanceof LogicError) {
|
|
118
|
+
let currentLine = logicError.teal_line - logicError.lines - 1;
|
|
119
|
+
const stackWithLines = logicError.stack
|
|
120
|
+
?.split('\n')
|
|
121
|
+
.map((line) => `${(currentLine += 1)}: ${line}`)
|
|
122
|
+
.join('\n');
|
|
123
|
+
Config.logger.error(`${logicError.message}\n\n${stackWithLines}`);
|
|
124
|
+
}
|
|
125
|
+
return logicError;
|
|
126
|
+
};
|
|
110
127
|
this._appId = params.appId;
|
|
111
128
|
this._appAddress = algosdk.getApplicationAddress(this._appId);
|
|
112
129
|
this._appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
113
130
|
this._appName = params.appName ?? this._appSpec.name;
|
|
114
131
|
this._algorand = params.algorand;
|
|
132
|
+
this._algorand.registerErrorTransformer(this.handleCallErrors);
|
|
115
133
|
this._defaultSender = typeof params.defaultSender === 'string' ? Address.fromString(params.defaultSender) : params.defaultSender;
|
|
116
134
|
this._defaultSigner = params.defaultSigner;
|
|
117
135
|
this._approvalSourceMap = params.approvalSourceMap;
|
|
@@ -725,29 +743,29 @@ class AppClient {
|
|
|
725
743
|
update: async (params) => {
|
|
726
744
|
const compiled = await this.compile(params);
|
|
727
745
|
return {
|
|
728
|
-
...(await this.
|
|
746
|
+
...(await this._algorand.send.appUpdate(await this.params.bare.update(params))),
|
|
729
747
|
...compiled,
|
|
730
748
|
};
|
|
731
749
|
},
|
|
732
750
|
/** Signs and sends an opt-in call */
|
|
733
751
|
optIn: (params) => {
|
|
734
|
-
return this.
|
|
752
|
+
return this._algorand.send.appCall(this.params.bare.optIn(params));
|
|
735
753
|
},
|
|
736
754
|
/** Signs and sends a delete call */
|
|
737
755
|
delete: (params) => {
|
|
738
|
-
return this.
|
|
756
|
+
return this._algorand.send.appDelete(this.params.bare.delete(params));
|
|
739
757
|
},
|
|
740
758
|
/** Signs and sends a clear state call */
|
|
741
759
|
clearState: (params) => {
|
|
742
|
-
return this.
|
|
760
|
+
return this._algorand.send.appCall(this.params.bare.clearState(params));
|
|
743
761
|
},
|
|
744
762
|
/** Signs and sends a close out call */
|
|
745
763
|
closeOut: (params) => {
|
|
746
|
-
return this.
|
|
764
|
+
return this._algorand.send.appCall(this.params.bare.closeOut(params));
|
|
747
765
|
},
|
|
748
766
|
/** Signs and sends a call (defaults to no-op) */
|
|
749
767
|
call: (params) => {
|
|
750
|
-
return this.
|
|
768
|
+
return this._algorand.send.appCall(this.params.bare.call(params));
|
|
751
769
|
},
|
|
752
770
|
};
|
|
753
771
|
}
|
|
@@ -826,7 +844,7 @@ class AppClient {
|
|
|
826
844
|
update: async (params) => {
|
|
827
845
|
const compiled = await this.compile(params);
|
|
828
846
|
return {
|
|
829
|
-
...(await this.
|
|
847
|
+
...(await this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), getArc56Method(params.method, this._appSpec))),
|
|
830
848
|
...compiled,
|
|
831
849
|
};
|
|
832
850
|
},
|
|
@@ -835,24 +853,24 @@ class AppClient {
|
|
|
835
853
|
* @param params The parameters for the opt-in ABI method call
|
|
836
854
|
* @returns The result of sending the opt-in ABI method call
|
|
837
855
|
*/
|
|
838
|
-
optIn: (params) => {
|
|
839
|
-
return this.
|
|
856
|
+
optIn: async (params) => {
|
|
857
|
+
return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), getArc56Method(params.method, this._appSpec));
|
|
840
858
|
},
|
|
841
859
|
/**
|
|
842
860
|
* Sign and send transactions for a delete ABI call
|
|
843
861
|
* @param params The parameters for the delete ABI method call
|
|
844
862
|
* @returns The result of sending the delete ABI method call
|
|
845
863
|
*/
|
|
846
|
-
delete: (params) => {
|
|
847
|
-
return this.
|
|
864
|
+
delete: async (params) => {
|
|
865
|
+
return this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), getArc56Method(params.method, this._appSpec));
|
|
848
866
|
},
|
|
849
867
|
/**
|
|
850
868
|
* Sign and send transactions for a close out ABI call
|
|
851
869
|
* @param params The parameters for the close out ABI method call
|
|
852
870
|
* @returns The result of sending the close out ABI method call
|
|
853
871
|
*/
|
|
854
|
-
closeOut: (params) => {
|
|
855
|
-
return this.
|
|
872
|
+
closeOut: async (params) => {
|
|
873
|
+
return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), getArc56Method(params.method, this._appSpec));
|
|
856
874
|
},
|
|
857
875
|
/**
|
|
858
876
|
* Sign and send transactions for a call (defaults to no-op)
|
|
@@ -902,7 +920,7 @@ class AppClient {
|
|
|
902
920
|
throw e;
|
|
903
921
|
}
|
|
904
922
|
}
|
|
905
|
-
return this.
|
|
923
|
+
return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), getArc56Method(params.method, this._appSpec));
|
|
906
924
|
},
|
|
907
925
|
};
|
|
908
926
|
}
|
|
@@ -994,24 +1012,6 @@ class AppClient {
|
|
|
994
1012
|
args,
|
|
995
1013
|
};
|
|
996
1014
|
}
|
|
997
|
-
/** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */
|
|
998
|
-
async handleCallErrors(call) {
|
|
999
|
-
try {
|
|
1000
|
-
return await call();
|
|
1001
|
-
}
|
|
1002
|
-
catch (e) {
|
|
1003
|
-
const logicError = await this.exposeLogicError(e);
|
|
1004
|
-
if (logicError instanceof LogicError) {
|
|
1005
|
-
let currentLine = logicError.teal_line - logicError.lines - 1;
|
|
1006
|
-
const stackWithLines = logicError.stack
|
|
1007
|
-
?.split('\n')
|
|
1008
|
-
.map((line) => `${(currentLine += 1)}: ${line}`)
|
|
1009
|
-
.join('\n');
|
|
1010
|
-
Config.logger.error(`${logicError.message}\n\n${stackWithLines}`);
|
|
1011
|
-
}
|
|
1012
|
-
throw logicError;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
1015
|
getBoxMethods() {
|
|
1016
1016
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1017
1017
|
const that = this;
|