From c9a2c92b0b7b626beecd3313def35639ede36b2f Mon Sep 17 00:00:00 2001 From: freeelancer Date: Fri, 8 Mar 2024 16:01:43 +0800 Subject: [PATCH] changed initialization --- .../v1/models/AuthorizationMsg.ts | 24 ++++++++++++------- .../smartaccount/v1/models/Initialization.ts | 18 +++++++++----- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/core/smartaccount/v1/models/AuthorizationMsg.ts b/src/core/smartaccount/v1/models/AuthorizationMsg.ts index 6b6611f..3000a5c 100644 --- a/src/core/smartaccount/v1/models/AuthorizationMsg.ts +++ b/src/core/smartaccount/v1/models/AuthorizationMsg.ts @@ -25,7 +25,10 @@ export class AuthorizationMsg extends JSONSerializable< const { value: { contractAddress, initMsg }, } = data; - return new AuthorizationMsg(contractAddress, initMsg); + return new AuthorizationMsg( + contractAddress, + Initialization.fromAmino(initMsg) + ); } public toAmino(): AuthorizationMsg.Amino { @@ -33,21 +36,24 @@ export class AuthorizationMsg extends JSONSerializable< return { value: { contractAddress, - initMsg, + initMsg: initMsg.toAmino(), }, }; } public static fromData(data: AuthorizationMsg.Data): AuthorizationMsg { - const { contractAddress, initMsg } = data; - return new AuthorizationMsg(contractAddress, initMsg); + const { contract_address, init_msg } = data; + return new AuthorizationMsg( + contract_address, + Initialization.fromData(init_msg) + ); } public toData(): AuthorizationMsg.Data { const { contractAddress, initMsg } = this; return { - contractAddress, - initMsg, + contract_address: contractAddress, + init_msg: initMsg.toData(), }; } @@ -81,13 +87,13 @@ export namespace AuthorizationMsg { export interface Amino { value: { contractAddress: string; - initMsg: Initialization; + initMsg: Initialization.Amino; }; } export interface Data { - contractAddress: string; - initMsg: Initialization; + contract_address: string; + init_msg: Initialization.Data; } export type Proto = AuthorizationMsg_pb; diff --git a/src/core/smartaccount/v1/models/Initialization.ts b/src/core/smartaccount/v1/models/Initialization.ts index 8011b64..b510940 100644 --- a/src/core/smartaccount/v1/models/Initialization.ts +++ b/src/core/smartaccount/v1/models/Initialization.ts @@ -28,31 +28,37 @@ export class Initialization extends JSONSerializable< const { value: { senders, account, msg }, } = data; - return new Initialization(senders, account, msg); + const buf = Buffer.from(msg, 'ascii'); + const msgBs = new Uint8Array(buf); + return new Initialization(senders, account, msgBs); } public toAmino(): Initialization.Amino { const { senders, account, msg } = this; + const base64Str = Buffer.from(msg).toString('ascii'); return { value: { senders, account, - msg, + msg: base64Str, }, }; } public static fromData(data: Initialization.Data): Initialization { const { senders, account, msg } = data; - return new Initialization(senders, account, msg); + const buf = Buffer.from(msg, 'ascii'); + const msgBs = new Uint8Array(buf); + return new Initialization(senders, account, msgBs); } public toData(): Initialization.Data { const { senders, account, msg } = this; + const base64Str = Buffer.from(msg).toString('ascii'); return { senders, account, - msg, + msg: base64Str, }; } @@ -85,14 +91,14 @@ export namespace Initialization { value: { senders: string[]; account: string; - msg: Uint8Array; + msg: string; }; } export interface Data { senders: string[]; account: string; - msg: Uint8Array; + msg: string; } export type Proto = Initialization_pb;