Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions expo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions expo/src/api/GnoNativeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
GenerateRecoveryPhraseRequest,
GetActiveAccountRequest,
GetActiveAccountResponse,
GetActivatedAccountRequest,
GetActivatedAccountResponse,
GetChainIDRequest,
GetKeyInfoByAddressRequest,
GetKeyInfoByNameOrAddressRequest,
Expand All @@ -32,6 +34,8 @@ import {
RenderRequest,
SelectAccountRequest,
SelectAccountResponse,
ActivateAccountRequest,
ActivateAccountResponse,
SendRequest,
SendResponse,
SetChainIDRequest,
Expand Down Expand Up @@ -213,6 +217,16 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
return response;
}

async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {
const client = await this.#getClient();
const response = await client.activateAccount(
new ActivateAccountRequest({
nameOrBech32,
}),
);
return response;
}

async getClient(): Promise<PromiseClient<typeof GnoNativeService>> {
if (!this.clientInstance) {
throw new Error('GoBridge client instance not initialized.');
Expand All @@ -224,15 +238,15 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
return this.clientInstance !== undefined;
}

async setPassword(password: string): Promise<SetPasswordResponse> {
async setPassword(password: string, address?: Uint8Array): Promise<SetPasswordResponse> {
const client = await this.#getClient();
const response = await client.setPassword(new SetPasswordRequest({ password }));
const response = await client.setPassword(new SetPasswordRequest({ password, address }));
return response;
}

async updatePassword(newPassword: string): Promise<UpdatePasswordResponse> {
async updatePassword(newPassword: string, address?: Uint8Array): Promise<UpdatePasswordResponse> {
const client = await this.#getClient();
const response = await client.updatePassword(new UpdatePasswordRequest({ newPassword }));
const response = await client.updatePassword(new UpdatePasswordRequest({ newPassword, address }));
return response;
}

Expand All @@ -242,6 +256,12 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
return response;
}

async getActivatedAccount(): Promise<GetActivatedAccountResponse> {
const client = await this.#getClient();
const response = await client.getActivatedAccount(new GetActivatedAccountRequest());
return response;
}

async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {
const client = await this.#getClient();
const reponse = await client.queryAccount(new QueryAccountRequest({ address }));
Expand Down Expand Up @@ -303,6 +323,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
args: string[],
gasFee: string,
gasWanted: number,
callerAddress?: Uint8Array,
send?: string,
memo?: string,
): Promise<AsyncIterable<CallResponse>> {
Expand All @@ -312,6 +333,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
gasFee,
gasWanted: BigInt(gasWanted),
memo,
callerAddress,
msgs: [
new MsgCall({
packagePath,
Expand All @@ -330,6 +352,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
send: string,
gasFee: string,
gasWanted: number,
callerAddress?: Uint8Array,
memo?: string,
): Promise<AsyncIterable<SendResponse>> {
const client = await this.#getClient();
Expand All @@ -338,6 +361,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
gasFee,
gasWanted: BigInt(gasWanted),
memo,
callerAddress,
msgs: [
new MsgSend({
toAddress,
Expand Down
10 changes: 8 additions & 2 deletions expo/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import {
CallResponse,
DeleteAccountResponse,
GetActiveAccountResponse,
GetActivatedAccountResponse,
HelloStreamResponse,
QueryAccountResponse,
QueryResponse,
SelectAccountResponse,
ActivateAccountResponse,
SendResponse,
SetChainIDResponse,
SetPasswordResponse,
Expand Down Expand Up @@ -46,9 +48,11 @@ export interface GnoKeyApi {
getKeyInfoByAddress: (address: Uint8Array) => Promise<KeyInfo | undefined>;
getKeyInfoByNameOrAddress: (nameOrBech32: string) => Promise<KeyInfo | undefined>;
selectAccount: (nameOrBech32: string) => Promise<SelectAccountResponse>;
setPassword: (password: string) => Promise<SetPasswordResponse>;
updatePassword: (password: string) => Promise<UpdatePasswordResponse>;
activateAccount: (nameOrBech32: string) => Promise<ActivateAccountResponse>;
setPassword: (password: string, address?: Uint8Array) => Promise<SetPasswordResponse>;
updatePassword: (password: string, address?: Uint8Array) => Promise<UpdatePasswordResponse>;
getActiveAccount: () => Promise<GetActiveAccountResponse>;
getActivatedAccount: () => Promise<GetActivatedAccountResponse>;
queryAccount: (address: Uint8Array) => Promise<QueryAccountResponse>;
deleteAccount: (
nameOrBech32: string,
Expand All @@ -64,6 +68,7 @@ export interface GnoKeyApi {
args: string[],
gasFee: string,
gasWanted: number,
callerAddress?: Uint8Array,
send?: string,
memo?: string,
) => Promise<AsyncIterable<CallResponse>>;
Expand All @@ -72,6 +77,7 @@ export interface GnoKeyApi {
send: string,
gasFee: string,
gasWanted: number,
callerAddress?: Uint8Array,
memo?: string,
) => Promise<AsyncIterable<SendResponse>>;
addressToBech32: (address: Uint8Array) => Promise<string>;
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
connectrpc.com/grpchealth v1.3.0
connectrpc.com/grpcreflect v1.2.0
github.com/gnolang/gno v0.1.2-0.20240826090356-651f5aac3706
github.com/gnolang/gnokey-mobile v0.0.0-20240814140149-eb333b936c7c
github.com/gnolang/gnokey-mobile v0.0.0-20240903152400-9942eff89ef6
github.com/oklog/run v1.1.0
github.com/peterbourgon/ff/v3 v3.4.0
github.com/peterbourgon/unixtransport v0.0.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ github.com/gnolang/gno v0.1.2-0.20240826090356-651f5aac3706 h1:0kpoNeuErRec3JOt3
github.com/gnolang/gno v0.1.2-0.20240826090356-651f5aac3706/go.mod h1:dBaL1Au2MNLol+3FXdCv+IKLJnMKtTmIt778zsKjVu0=
github.com/gnolang/gnokey-mobile v0.0.0-20240814140149-eb333b936c7c h1:rL7dVjWOpdQxmbsh69HrgAklolhydTZmPvgo6BpgdhE=
github.com/gnolang/gnokey-mobile v0.0.0-20240814140149-eb333b936c7c/go.mod h1:2NrHp15t6QXGNDruOpw6/xN6z50kquVvZs6uxvUNhsQ=
github.com/gnolang/gnokey-mobile v0.0.0-20240903152400-9942eff89ef6 h1:D4dctoTOCk30fbMebwgDYRhcemXrcK7vqjl6MFPUIfc=
github.com/gnolang/gnokey-mobile v0.0.0-20240903152400-9942eff89ef6/go.mod h1:fD0uCByVS8JKxQbSPOvJxO0s7vdfh1BBXBcv8d+ApDk=
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 h1:GKvsK3oLWG9B1GL7WP/VqwM6C92j5tIvB844oggL9Lk=
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216/go.mod h1:xJhtEL7ahjM1WJipt89gel8tHzfIl/LyMY+lCYh38d8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down