Skip to content

Commit

Permalink
chore: adjust Initialization model
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Mar 12, 2024
1 parent c9a2c92 commit 708ce63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7",
"@terra-money/terra.proto": "5.1.0-beta.2",
"@terra-money/terra.proto": "^5.1.0-beta.3",
"assert": "^2.0.0",
"axios": "^0.27.2",
"bech32": "^2.0.0",
Expand All @@ -104,4 +104,4 @@
"utf-8-validate": "^5.0.5",
"ws": "^7.5.9"
}
}
}
27 changes: 9 additions & 18 deletions src/core/smartaccount/v1/models/Initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,53 @@ export class Initialization extends JSONSerializable<
* @param contractAddress contract address of authorization logic
* @param initMsg initial message to be passed to the contract
*/
constructor(
public senders: string[],
public account: string,
public msg: Uint8Array
) {
constructor(public account: string, public msg: Uint8Array) {
super();
}

public static fromAmino(data: Initialization.Amino): Initialization {
const {
value: { senders, account, msg },
value: { account, msg },
} = data;
const buf = Buffer.from(msg, 'ascii');
const msgBs = new Uint8Array(buf);
return new Initialization(senders, account, msgBs);
return new Initialization(account, msgBs);
}

public toAmino(): Initialization.Amino {
const { senders, account, msg } = this;
const { account, msg } = this;
const base64Str = Buffer.from(msg).toString('ascii');
return {
value: {
senders,
account,
msg: base64Str,
},
};
}

public static fromData(data: Initialization.Data): Initialization {
const { senders, account, msg } = data;
const { account, msg } = data;
const buf = Buffer.from(msg, 'ascii');
const msgBs = new Uint8Array(buf);
return new Initialization(senders, account, msgBs);
return new Initialization(account, msgBs);
}

public toData(): Initialization.Data {
const { senders, account, msg } = this;
const { account, msg } = this;
const base64Str = Buffer.from(msg).toString('ascii');
return {
senders,
account,
msg: base64Str,
};
}

public static fromProto(proto: Initialization.Proto): Initialization {
return new Initialization(proto.senders, proto.account, proto.msg);
return new Initialization(proto.account, proto.msg);
}

public toProto(): Initialization.Proto {
const { senders, account, msg } = this;
const { account, msg } = this;
return Initialization_pb.fromPartial({
senders,
account,
msg,
});
Expand All @@ -89,14 +82,12 @@ export class Initialization extends JSONSerializable<
export namespace Initialization {
export interface Amino {
value: {
senders: string[];
account: string;
msg: string;
};
}

export interface Data {
senders: string[];
account: string;
msg: string;
}
Expand Down

0 comments on commit 708ce63

Please sign in to comment.