Skip to content

Commit

Permalink
fix: adjust types to support tsc in non strict mode (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell authored Dec 17, 2024
1 parent 4624eff commit d09bf37
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 169 deletions.
8 changes: 4 additions & 4 deletions examples/arc56_test/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export class Arc56TestFactory {
public async deploy(params: Arc56TestDeployParams = {}) {
const result = await this.appFactory.deploy({
...params,
createParams: params.createParams?.method ? Arc56TestParamsFactory.create._resolveByMethod(params.createParams) : params.createParams,
createParams: params.createParams?.method ? Arc56TestParamsFactory.create._resolveByMethod(params.createParams) : params.createParams ? params.createParams as (Arc56TestCreateCallParams & { args: Uint8Array[] }) : undefined,
})
return { result: result.result, appClient: new Arc56TestClient(result.appClient) }
}
Expand Down Expand Up @@ -469,7 +469,7 @@ export class Arc56TestFactory {
*/
createApplication: async (params: CallParams<Arc56TestArgs['obj']['createApplication()void'] | Arc56TestArgs['tuple']['createApplication()void']> & AppClientCompilationParams & CreateSchema & SendParams & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => {
const result = await this.appFactory.send.create(Arc56TestParamsFactory.create.createApplication(params))
return { result: { ...result.result, return: result.result.return as undefined | Arc56TestReturns['createApplication()void'] }, appClient: new Arc56TestClient(result.appClient) }
return { result: { ...result.result, return: result.result.return as unknown as (undefined | Arc56TestReturns['createApplication()void']) }, appClient: new Arc56TestClient(result.appClient) }
},
},

Expand Down Expand Up @@ -659,7 +659,7 @@ export class Arc56TestClient {
*/
optInToApplication: async (params: CallParams<Arc56TestArgs['obj']['optInToApplication()void'] | Arc56TestArgs['tuple']['optInToApplication()void']> & SendParams = {args: []}) => {
const result = await this.appClient.send.optIn(Arc56TestParamsFactory.optIn.optInToApplication(params))
return {...result, return: result.return as undefined | Arc56TestReturns['optInToApplication()void']}
return {...result, return: result.return as unknown as (undefined | Arc56TestReturns['optInToApplication()void'])}
},

},
Expand All @@ -682,7 +682,7 @@ export class Arc56TestClient {
*/
foo: async (params: CallParams<Arc56TestArgs['obj']['foo(((uint64,uint64),(uint64,uint64)))(uint64,uint64)'] | Arc56TestArgs['tuple']['foo(((uint64,uint64),(uint64,uint64)))(uint64,uint64)']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(Arc56TestParamsFactory.foo(params))
return {...result, return: result.return as undefined | Arc56TestReturns['foo(((uint64,uint64),(uint64,uint64)))(uint64,uint64)']}
return {...result, return: result.return as unknown as (undefined | Arc56TestReturns['foo(((uint64,uint64),(uint64,uint64)))(uint64,uint64)'])}
},

}
Expand Down
6 changes: 3 additions & 3 deletions examples/duplicate_structs/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export type MethodReturn<TSignature extends DuplicateStructsContractSignatures>
* Defines supported create method params for this smart contract
*/
export type DuplicateStructsContractCreateCallParams =
| Expand<AppClientBareCallParams & {method?: undefined} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines arguments required for the deploy method.
*/
Expand Down Expand Up @@ -520,7 +520,7 @@ export class DuplicateStructsContractClient {
*/
methodAThatUsesStruct: async (params: CallParams<DuplicateStructsContractArgs['obj']['method_a_that_uses_struct()(uint64,uint64)'] | DuplicateStructsContractArgs['tuple']['method_a_that_uses_struct()(uint64,uint64)']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => {
const result = await this.appClient.send.call(DuplicateStructsContractParamsFactory.methodAThatUsesStruct(params))
return {...result, return: result.return as undefined | DuplicateStructsContractReturns['method_a_that_uses_struct()(uint64,uint64)']}
return {...result, return: result.return as unknown as (undefined | DuplicateStructsContractReturns['method_a_that_uses_struct()(uint64,uint64)'])}
},

/**
Expand All @@ -531,7 +531,7 @@ export class DuplicateStructsContractClient {
*/
methodBThatUsesSameStruct: async (params: CallParams<DuplicateStructsContractArgs['obj']['method_b_that_uses_same_struct()(uint64,uint64)'] | DuplicateStructsContractArgs['tuple']['method_b_that_uses_same_struct()(uint64,uint64)']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => {
const result = await this.appClient.send.call(DuplicateStructsContractParamsFactory.methodBThatUsesSameStruct(params))
return {...result, return: result.return as undefined | DuplicateStructsContractReturns['method_b_that_uses_same_struct()(uint64,uint64)']}
return {...result, return: result.return as unknown as (undefined | DuplicateStructsContractReturns['method_b_that_uses_same_struct()(uint64,uint64)'])}
},

}
Expand Down
10 changes: 5 additions & 5 deletions examples/helloworld/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ export type MethodReturn<TSignature extends HelloWorldAppSignatures> = HelloWorl
* Defines supported create method params for this smart contract
*/
export type HelloWorldAppCreateCallParams =
| Expand<AppClientBareCallParams & {method?: undefined} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines supported update method params for this smart contract
*/
export type HelloWorldAppUpdateCallParams =
| Expand<AppClientBareCallParams> & {method?: undefined}
| Expand<AppClientBareCallParams> & {method?: never}
/**
* Defines supported delete method params for this smart contract
*/
export type HelloWorldAppDeleteCallParams =
| Expand<AppClientBareCallParams> & {method?: undefined}
| Expand<AppClientBareCallParams> & {method?: never}
/**
* Defines arguments required for the deploy method.
*/
Expand Down Expand Up @@ -661,7 +661,7 @@ export class HelloWorldAppClient {
*/
hello: async (params: CallParams<HelloWorldAppArgs['obj']['hello(string)string'] | HelloWorldAppArgs['tuple']['hello(string)string']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(HelloWorldAppParamsFactory.hello(params))
return {...result, return: result.return as undefined | HelloWorldAppReturns['hello(string)string']}
return {...result, return: result.return as unknown as (undefined | HelloWorldAppReturns['hello(string)string'])}
},

/**
Expand All @@ -674,7 +674,7 @@ export class HelloWorldAppClient {
*/
helloWorldCheck: async (params: CallParams<HelloWorldAppArgs['obj']['hello_world_check(string)void'] | HelloWorldAppArgs['tuple']['hello_world_check(string)void']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(HelloWorldAppParamsFactory.helloWorldCheck(params))
return {...result, return: result.return as undefined | HelloWorldAppReturns['hello_world_check(string)void']}
return {...result, return: result.return as unknown as (undefined | HelloWorldAppReturns['hello_world_check(string)void'])}
},

}
Expand Down
14 changes: 7 additions & 7 deletions examples/lifecycle/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ export type GlobalKeysState = LifeCycleAppTypes['state']['global']['keys']
* Defines supported create method params for this smart contract
*/
export type LifeCycleAppCreateCallParams =
| Expand<AppClientBareCallParams & {method?: undefined} & {onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC} & CreateSchema>
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC} & CreateSchema>
| Expand<CallParams<LifeCycleAppArgs['obj']['create(string)string'] | LifeCycleAppArgs['tuple']['create(string)string']> & {method: 'create(string)string'} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
| Expand<CallParams<LifeCycleAppArgs['obj']['create(string,uint32)void'] | LifeCycleAppArgs['tuple']['create(string,uint32)void']> & {method: 'create(string,uint32)void'} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines supported update method params for this smart contract
*/
export type LifeCycleAppUpdateCallParams =
| Expand<AppClientBareCallParams> & {method?: undefined}
| Expand<AppClientBareCallParams> & {method?: never}
/**
* Defines arguments required for the deploy method.
*/
Expand Down Expand Up @@ -360,7 +360,7 @@ export class LifeCycleAppFactory {
public async deploy(params: LifeCycleAppDeployParams = {}) {
const result = await this.appFactory.deploy({
...params,
createParams: params.createParams?.method ? LifeCycleAppParamsFactory.create._resolveByMethod(params.createParams) : params.createParams,
createParams: params.createParams?.method ? LifeCycleAppParamsFactory.create._resolveByMethod(params.createParams) : params.createParams ? params.createParams as (LifeCycleAppCreateCallParams & { args: Uint8Array[] }) : undefined,
})
return { result: result.result, appClient: new LifeCycleAppClient(result.appClient) }
}
Expand Down Expand Up @@ -494,7 +494,7 @@ export class LifeCycleAppFactory {
*/
createStringString: async (params: CallParams<LifeCycleAppArgs['obj']['create(string)string'] | LifeCycleAppArgs['tuple']['create(string)string']> & AppClientCompilationParams & CreateSchema & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appFactory.send.create(LifeCycleAppParamsFactory.create.createStringString(params))
return { result: { ...result.result, return: result.result.return as undefined | LifeCycleAppReturns['create(string)string'] }, appClient: new LifeCycleAppClient(result.appClient) }
return { result: { ...result.result, return: result.result.return as unknown as (undefined | LifeCycleAppReturns['create(string)string']) }, appClient: new LifeCycleAppClient(result.appClient) }
},
/**
* Creates a new instance of the LifeCycleApp smart contract using an ABI method call using the create(string,uint32)void ABI method.
Expand All @@ -506,7 +506,7 @@ export class LifeCycleAppFactory {
*/
createStringUint32Void: async (params: CallParams<LifeCycleAppArgs['obj']['create(string,uint32)void'] | LifeCycleAppArgs['tuple']['create(string,uint32)void']> & AppClientCompilationParams & CreateSchema & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appFactory.send.create(LifeCycleAppParamsFactory.create.createStringUint32Void(params))
return { result: { ...result.result, return: result.result.return as undefined | LifeCycleAppReturns['create(string,uint32)void'] }, appClient: new LifeCycleAppClient(result.appClient) }
return { result: { ...result.result, return: result.result.return as unknown as (undefined | LifeCycleAppReturns['create(string,uint32)void']) }, appClient: new LifeCycleAppClient(result.appClient) }
},
},

Expand Down Expand Up @@ -735,7 +735,7 @@ export class LifeCycleAppClient {
*/
helloStringString: async (params: CallParams<LifeCycleAppArgs['obj']['hello(string)string'] | LifeCycleAppArgs['tuple']['hello(string)string']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(LifeCycleAppParamsFactory.helloStringString(params))
return {...result, return: result.return as undefined | LifeCycleAppReturns['hello(string)string']}
return {...result, return: result.return as unknown as (undefined | LifeCycleAppReturns['hello(string)string'])}
},

/**
Expand All @@ -746,7 +746,7 @@ export class LifeCycleAppClient {
*/
helloString: async (params: CallParams<LifeCycleAppArgs['obj']['hello()string'] | LifeCycleAppArgs['tuple']['hello()string']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => {
const result = await this.appClient.send.call(LifeCycleAppParamsFactory.helloString(params))
return {...result, return: result.return as undefined | LifeCycleAppReturns['hello()string']}
return {...result, return: result.return as unknown as (undefined | LifeCycleAppReturns['hello()string'])}
},

}
Expand Down
6 changes: 3 additions & 3 deletions examples/minimal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ export type MethodReturn<TSignature extends AppSignatures> = AppTypes['methods']
* Defines supported create method params for this smart contract
*/
export type AppCreateCallParams =
| Expand<AppClientBareCallParams & {method?: undefined} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines supported update method params for this smart contract
*/
export type AppUpdateCallParams =
| Expand<AppClientBareCallParams> & {method?: undefined}
| Expand<AppClientBareCallParams> & {method?: never}
/**
* Defines supported delete method params for this smart contract
*/
export type AppDeleteCallParams =
| Expand<AppClientBareCallParams> & {method?: undefined}
| Expand<AppClientBareCallParams> & {method?: never}
/**
* Defines arguments required for the deploy method.
*/
Expand Down
8 changes: 4 additions & 4 deletions examples/nested/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export type MethodReturn<TSignature extends NestedContractSignatures> = NestedCo
* Defines supported create method params for this smart contract
*/
export type NestedContractCreateCallParams =
| Expand<AppClientBareCallParams & {method?: undefined} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines arguments required for the deploy method.
*/
Expand Down Expand Up @@ -555,7 +555,7 @@ export class NestedContractClient {
*/
add: async (params: CallParams<NestedContractArgs['obj']['add(uint64,uint64)uint64'] | NestedContractArgs['tuple']['add(uint64,uint64)uint64']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(NestedContractParamsFactory.add(params))
return {...result, return: result.return as undefined | NestedContractReturns['add(uint64,uint64)uint64']}
return {...result, return: result.return as unknown as (undefined | NestedContractReturns['add(uint64,uint64)uint64'])}
},

/**
Expand All @@ -566,7 +566,7 @@ export class NestedContractClient {
*/
getPayTxnAmount: async (params: CallParams<NestedContractArgs['obj']['get_pay_txn_amount(pay)uint64'] | NestedContractArgs['tuple']['get_pay_txn_amount(pay)uint64']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(NestedContractParamsFactory.getPayTxnAmount(params))
return {...result, return: result.return as undefined | NestedContractReturns['get_pay_txn_amount(pay)uint64']}
return {...result, return: result.return as unknown as (undefined | NestedContractReturns['get_pay_txn_amount(pay)uint64'])}
},

/**
Expand All @@ -577,7 +577,7 @@ export class NestedContractClient {
*/
nestedMethodCall: async (params: CallParams<NestedContractArgs['obj']['nested_method_call(string,pay,appl)byte[]'] | NestedContractArgs['tuple']['nested_method_call(string,pay,appl)byte[]']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(NestedContractParamsFactory.nestedMethodCall(params))
return {...result, return: result.return as undefined | NestedContractReturns['nested_method_call(string,pay,appl)byte[]']}
return {...result, return: result.return as unknown as (undefined | NestedContractReturns['nested_method_call(string,pay,appl)byte[]'])}
},

}
Expand Down
Loading

0 comments on commit d09bf37

Please sign in to comment.