-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
363 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"version": "v3.9.0", | ||
"name": "InlineTest", | ||
"bytecode": "01011f01010000010ad3811965ccb413c32386f26fc10000a9a0000d2aa100a00002", | ||
"codeHash": "5ec60ac0a6e53a40956d05de67ea90fd9ca958e6fea80e0f1c44c3fe0395871e", | ||
"fieldsSig": { | ||
"names": [ | ||
"count" | ||
], | ||
"types": [ | ||
"U256" | ||
], | ||
"isMutable": [ | ||
true | ||
] | ||
}, | ||
"eventsSig": [], | ||
"functions": [ | ||
{ | ||
"name": "nextCount", | ||
"paramNames": [], | ||
"paramTypes": [], | ||
"paramIsMutable": [], | ||
"returnTypes": [ | ||
"U256" | ||
] | ||
}, | ||
{ | ||
"name": "nextCount_", | ||
"paramNames": [], | ||
"paramTypes": [], | ||
"paramIsMutable": [], | ||
"returnTypes": [ | ||
"U256" | ||
] | ||
} | ||
], | ||
"constants": [], | ||
"enums": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
import { | ||
Address, | ||
Contract, | ||
ContractState, | ||
TestContractResult, | ||
HexString, | ||
ContractFactory, | ||
EventSubscribeOptions, | ||
EventSubscription, | ||
CallContractParams, | ||
CallContractResult, | ||
TestContractParams, | ||
ContractEvent, | ||
subscribeContractEvent, | ||
subscribeContractEvents, | ||
testMethod, | ||
callMethod, | ||
multicallMethods, | ||
fetchContractState, | ||
Asset, | ||
ContractInstance, | ||
getContractEventsCurrentCount, | ||
TestContractParamsWithoutMaps, | ||
TestContractResultWithoutMaps, | ||
SignExecuteContractMethodParams, | ||
SignExecuteScriptTxResult, | ||
signExecuteMethod, | ||
addStdIdToFields, | ||
encodeContractFields, | ||
Narrow, | ||
} from "@alephium/web3"; | ||
import { default as InlineTestContractJson } from "../test/InlineTest.ral.json"; | ||
import { getContractByCodeHash, registerContract } from "./contracts"; | ||
import { | ||
AddStruct1, | ||
AddStruct2, | ||
Balances, | ||
MapValue, | ||
TokenBalance, | ||
AllStructs, | ||
} from "./types"; | ||
|
||
// Custom types for the contract | ||
export namespace InlineTestTypes { | ||
export type Fields = { | ||
count: bigint; | ||
}; | ||
|
||
export type State = ContractState<Fields>; | ||
|
||
export interface CallMethodTable { | ||
nextCount: { | ||
params: Omit<CallContractParams<{}>, "args">; | ||
result: CallContractResult<bigint>; | ||
}; | ||
nextCount_: { | ||
params: Omit<CallContractParams<{}>, "args">; | ||
result: CallContractResult<bigint>; | ||
}; | ||
} | ||
export type CallMethodParams<T extends keyof CallMethodTable> = | ||
CallMethodTable[T]["params"]; | ||
export type CallMethodResult<T extends keyof CallMethodTable> = | ||
CallMethodTable[T]["result"]; | ||
export type MultiCallParams = Partial<{ | ||
[Name in keyof CallMethodTable]: CallMethodTable[Name]["params"]; | ||
}>; | ||
export type MultiCallResults<T extends MultiCallParams> = { | ||
[MaybeName in keyof T]: MaybeName extends keyof CallMethodTable | ||
? CallMethodTable[MaybeName]["result"] | ||
: undefined; | ||
}; | ||
export type MulticallReturnType<Callss extends MultiCallParams[]> = { | ||
[index in keyof Callss]: MultiCallResults<Callss[index]>; | ||
}; | ||
|
||
export interface SignExecuteMethodTable { | ||
nextCount: { | ||
params: Omit<SignExecuteContractMethodParams<{}>, "args">; | ||
result: SignExecuteScriptTxResult; | ||
}; | ||
nextCount_: { | ||
params: Omit<SignExecuteContractMethodParams<{}>, "args">; | ||
result: SignExecuteScriptTxResult; | ||
}; | ||
} | ||
export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> = | ||
SignExecuteMethodTable[T]["params"]; | ||
export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> = | ||
SignExecuteMethodTable[T]["result"]; | ||
} | ||
|
||
class Factory extends ContractFactory< | ||
InlineTestInstance, | ||
InlineTestTypes.Fields | ||
> { | ||
encodeFields(fields: InlineTestTypes.Fields) { | ||
return encodeContractFields( | ||
addStdIdToFields(this.contract, fields), | ||
this.contract.fieldsSig, | ||
AllStructs | ||
); | ||
} | ||
|
||
at(address: string): InlineTestInstance { | ||
return new InlineTestInstance(address); | ||
} | ||
|
||
tests = { | ||
nextCount: async ( | ||
params: Omit< | ||
TestContractParamsWithoutMaps<InlineTestTypes.Fields, never>, | ||
"testArgs" | ||
> | ||
): Promise<TestContractResultWithoutMaps<bigint>> => { | ||
return testMethod(this, "nextCount", params, getContractByCodeHash); | ||
}, | ||
nextCount_: async ( | ||
params: Omit< | ||
TestContractParamsWithoutMaps<InlineTestTypes.Fields, never>, | ||
"testArgs" | ||
> | ||
): Promise<TestContractResultWithoutMaps<bigint>> => { | ||
return testMethod(this, "nextCount_", params, getContractByCodeHash); | ||
}, | ||
}; | ||
|
||
stateForTest( | ||
initFields: InlineTestTypes.Fields, | ||
asset?: Asset, | ||
address?: string | ||
) { | ||
return this.stateForTest_(initFields, asset, address, undefined); | ||
} | ||
} | ||
|
||
// Use this object to test and deploy the contract | ||
export const InlineTest = new Factory( | ||
Contract.fromJson( | ||
InlineTestContractJson, | ||
"=3-1+2=2+4039=62+000000000109b413c32386f26fc10000a9a0000d2aa100a00002", | ||
"42eaecd6f4e1bc5a298fefad983fc698fd826d112ee83ab190e155eacb51d74e", | ||
AllStructs | ||
) | ||
); | ||
registerContract(InlineTest); | ||
|
||
// Use this class to interact with the blockchain | ||
export class InlineTestInstance extends ContractInstance { | ||
constructor(address: Address) { | ||
super(address); | ||
} | ||
|
||
async fetchState(): Promise<InlineTestTypes.State> { | ||
return fetchContractState(InlineTest, this); | ||
} | ||
|
||
view = { | ||
nextCount: async ( | ||
params?: InlineTestTypes.CallMethodParams<"nextCount"> | ||
): Promise<InlineTestTypes.CallMethodResult<"nextCount">> => { | ||
return callMethod( | ||
InlineTest, | ||
this, | ||
"nextCount", | ||
params === undefined ? {} : params, | ||
getContractByCodeHash | ||
); | ||
}, | ||
nextCount_: async ( | ||
params?: InlineTestTypes.CallMethodParams<"nextCount_"> | ||
): Promise<InlineTestTypes.CallMethodResult<"nextCount_">> => { | ||
return callMethod( | ||
InlineTest, | ||
this, | ||
"nextCount_", | ||
params === undefined ? {} : params, | ||
getContractByCodeHash | ||
); | ||
}, | ||
}; | ||
|
||
transact = { | ||
nextCount: async ( | ||
params: InlineTestTypes.SignExecuteMethodParams<"nextCount"> | ||
): Promise<InlineTestTypes.SignExecuteMethodResult<"nextCount">> => { | ||
return signExecuteMethod(InlineTest, this, "nextCount", params); | ||
}, | ||
nextCount_: async ( | ||
params: InlineTestTypes.SignExecuteMethodParams<"nextCount_"> | ||
): Promise<InlineTestTypes.SignExecuteMethodResult<"nextCount_">> => { | ||
return signExecuteMethod(InlineTest, this, "nextCount_", params); | ||
}, | ||
}; | ||
|
||
async multicall<Calls extends InlineTestTypes.MultiCallParams>( | ||
calls: Calls | ||
): Promise<InlineTestTypes.MultiCallResults<Calls>>; | ||
async multicall<Callss extends InlineTestTypes.MultiCallParams[]>( | ||
callss: Narrow<Callss> | ||
): Promise<InlineTestTypes.MulticallReturnType<Callss>>; | ||
async multicall< | ||
Callss extends | ||
| InlineTestTypes.MultiCallParams | ||
| InlineTestTypes.MultiCallParams[] | ||
>(callss: Callss): Promise<unknown> { | ||
return await multicallMethods( | ||
InlineTest, | ||
this, | ||
callss, | ||
getContractByCodeHash | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Contract InlineTest(mut count: U256) { | ||
@inline fn nextCount_() -> U256 { | ||
transferTokenToSelf!(callerAddress!(), ALPH, 0.01 alph) | ||
count = count + 1 | ||
return count | ||
} | ||
|
||
@using(updateFields = true, checkExternalCaller = false, preapprovedAssets = true, assetsInContract = true) | ||
pub fn nextCount() -> U256 { | ||
return nextCount_() | ||
} | ||
} |
Oops, something went wrong.