-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from initia-labs/feat/add-vm
Feat/add-vm
- Loading branch information
Showing
25 changed files
with
1,649 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,79 @@ | ||
import { AccAddress, EvmParams } from '../../../core'; | ||
import { APIParams } from '../APIRequester'; | ||
import { BaseAPI } from './BaseAPI'; | ||
|
||
export interface CallResponse { | ||
response: string; | ||
used_gas: string; | ||
logs: { | ||
address: AccAddress; | ||
topics: string[]; | ||
data: string; | ||
}[]; | ||
trace_output: string; | ||
} | ||
|
||
export class EvmAPI extends BaseAPI { | ||
public async code( | ||
contractAddr: AccAddress, | ||
params: APIParams = {} | ||
): Promise<string> { | ||
return this.c | ||
.get<{ code: string }>(`/minievm/evm/v1/codes/${contractAddr}`, params) | ||
.then(d => d.code); | ||
} | ||
|
||
public async state( | ||
contractAddr: AccAddress, | ||
key: string, | ||
params: APIParams = {} | ||
): Promise<string> { | ||
return this.c | ||
.get<{ value: string }>( | ||
`/minievm/evm/v1/states/${contractAddr}/${key}`, | ||
params | ||
) | ||
.then(d => d.value); | ||
} | ||
|
||
public async contractAddrByDenom( | ||
denom: string, | ||
params: APIParams = {} | ||
): Promise<AccAddress> { | ||
return this.c | ||
.get<{ address: AccAddress }>(`/minievm/evm/v1/contracts/by_denom`, { | ||
...params, | ||
denom, | ||
}) | ||
.then(d => d.address); | ||
} | ||
|
||
public async denom( | ||
contractAddr: AccAddress, | ||
params: APIParams = {} | ||
): Promise<string> { | ||
return this.c | ||
.get<{ denom: string }>(`/minievm/evm/v1/denoms/${contractAddr}`, params) | ||
.then(d => d.denom); | ||
} | ||
|
||
public async call( | ||
sender: AccAddress, | ||
contractAddr: AccAddress, | ||
input: string, | ||
withTrace: boolean | ||
): Promise<CallResponse> { | ||
return this.c.post<CallResponse>(`/minievm/evm/v1/call`, { | ||
sender, | ||
contract_addr: contractAddr, | ||
input, | ||
with_trace: withTrace, | ||
}); | ||
} | ||
|
||
public async parameters(params: APIParams = {}): Promise<EvmParams> { | ||
return this.c | ||
.get<{ params: EvmParams.Data }>(`/minievm/evm/v1/params`, params) | ||
.then(({ params: d }) => EvmParams.fromData(d)); | ||
} | ||
} |
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,54 @@ | ||
import { TokenfactoryParams } from '../../../core'; | ||
import { APIParams } from '../APIRequester'; | ||
import { BaseAPI } from './BaseAPI'; | ||
|
||
export interface AuthorityMetadata { | ||
admin: string; | ||
} | ||
|
||
export class TokenfactoryAPI extends BaseAPI { | ||
public async authorityMetadata( | ||
denom: string, | ||
params: APIParams = {} | ||
): Promise<AuthorityMetadata> { | ||
return this.c | ||
.get<{ authority_metadata: AuthorityMetadata }>( | ||
`/miniwasm/tokenfactory/v1/denoms/${denom}/authority_metadata`, | ||
params | ||
) | ||
.then(d => d.authority_metadata); | ||
} | ||
|
||
public async beforeSendHookAddr( | ||
denom: string, | ||
params: APIParams = {} | ||
): Promise<string> { | ||
return this.c | ||
.get<{ cosmwasm_address: string }>( | ||
`/miniwasm/tokenfactory/v1/denoms/${denom}/before_send_hook`, | ||
params | ||
) | ||
.then(d => d.cosmwasm_address); | ||
} | ||
|
||
public async denomsFromCreator( | ||
creator: string, | ||
params: APIParams = {} | ||
): Promise<string[]> { | ||
return this.c | ||
.get<{ denoms: string[] }>( | ||
`/miniwasm/tokenfactory/v1/denoms_from_creator/${creator}`, | ||
params | ||
) | ||
.then(d => d.denoms); | ||
} | ||
|
||
public async parameters(params: APIParams = {}): Promise<TokenfactoryParams> { | ||
return this.c | ||
.get<{ params: TokenfactoryParams.Data }>( | ||
`/miniwasm/tokenfactory/v1/params`, | ||
params | ||
) | ||
.then(({ params: d }) => TokenfactoryParams.fromData(d)); | ||
} | ||
} |
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
Oops, something went wrong.