@algorandfoundation/algokit-utils 7.0.0-beta.20 → 7.0.0-beta.22

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.
@@ -123,6 +123,12 @@ class AppClient {
123
123
  bare: this.getBareSendMethods(),
124
124
  };
125
125
  }
126
+ /**
127
+ * Clone this app client with different params
128
+ *
129
+ * @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.
130
+ * @returns A new app client with the altered params
131
+ */
126
132
  clone(params) {
127
133
  return new AppClient({
128
134
  appId: this._appId,
@@ -547,19 +553,22 @@ class AppClient {
547
553
  if (defaultValue) {
548
554
  switch (defaultValue.source) {
549
555
  case 'literal':
550
- if (typeof defaultValue.data === 'number')
551
- return defaultValue.data;
552
556
  return getABIDecodedValue(Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
553
- // todo: When ARC-56 supports ABI calls as default args
554
- // case 'abi': {
555
- // const method = this.getABIMethod(defaultValue.data as string)
556
- // const result = await this.send.call({
557
- // method: defaultValue.data as string,
558
- // methodArgs: method.args.map(() => undefined),
559
- // sender,
560
- // })
561
- // return result.return!
562
- // }
557
+ case 'method': {
558
+ const method = this.getABIMethod(defaultValue.data);
559
+ const result = await this.send.call({
560
+ method: defaultValue.data,
561
+ args: method.args.map(() => undefined),
562
+ sender,
563
+ });
564
+ if (result.return === undefined) {
565
+ throw new Error('Default value method call did not return a value');
566
+ }
567
+ if (typeof result.return === 'object' && !(result.return instanceof Uint8Array) && !Array.isArray(result.return)) {
568
+ return getABITupleFromABIStruct(result.return, this._appSpec.structs[method.returns.struct], this._appSpec.structs);
569
+ }
570
+ return result.return;
571
+ }
563
572
  case 'local':
564
573
  case 'global': {
565
574
  const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);