Skip to content

Commit

Permalink
Merge pull request #47 from cosmology-tech/sign-mode-names
Browse files Browse the repository at this point in the history
change sign mode names
  • Loading branch information
Zetazzz authored Oct 21, 2024
2 parents 3f5af37 + dfefb2f commit 817d034
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions networks/cosmos/src/base/base-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ implements ICosmosWallet, OfflineAminoSigner, OfflineDirectSigner
*/
toGeneralOfflineSigner(signMode: string): ICosmosGeneralOfflineSigner {
switch (signMode) {
case SIGN_MODE.SIGN_MODE_DIRECT:
case SIGN_MODE.DIRECT:
return {
signMode: signMode,
getAccounts: async () => this.getAccounts(),
sign: async ({ signerAddress, signDoc }: IGeneralOfflineSignArgs<string, CosmosDirectDoc>) =>
this.signDirect(signerAddress, signDoc),
};
case SIGN_MODE.SIGN_MODE_LEGACY_AMINO_JSON:
case SIGN_MODE.AMINO:
return {
signMode: signMode,
getAccounts: async () => this.getAccounts(),
Expand Down
4 changes: 2 additions & 2 deletions networks/cosmos/src/signing-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class SigningClient {
let signers;

switch (this.offlineSigner.signMode) {
case SIGN_MODE.SIGN_MODE_DIRECT:
case SIGN_MODE.DIRECT:
signers = await DirectSigner.fromWalletToSigners(
this.offlineSigner as IDirectGeneralOfflineSigner,
this.encoders,
Expand All @@ -103,7 +103,7 @@ export class SigningClient {
)
break;

case SIGN_MODE.SIGN_MODE_LEGACY_AMINO_JSON:
case SIGN_MODE.AMINO:
signers = await AminoSigner.fromWalletToSigners(
this.offlineSigner as IAminoGeneralOfflineSigner,
this.encoders,
Expand Down
4 changes: 2 additions & 2 deletions networks/cosmos/src/types/docAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class AminoDocAuth extends BaseDocAuth<OfflineAminoSigner | IAminoGeneral
}

static async fromGeneralOfflineSigner(offlineSigner: IAminoGeneralOfflineSigner) {
if(offlineSigner.signMode !== SIGN_MODE.SIGN_MODE_LEGACY_AMINO_JSON) {
if(offlineSigner.signMode !== SIGN_MODE.AMINO) {
throw new Error('not an amino general offline signer');
}

Expand Down Expand Up @@ -126,7 +126,7 @@ export class DirectDocAuth extends BaseDocAuth<OfflineDirectSigner | IDirectGene
}

static async fromGeneralOfflineSigner(offlineSigner: IDirectGeneralOfflineSigner) {
if(offlineSigner.signMode !== SIGN_MODE.SIGN_MODE_DIRECT) {
if(offlineSigner.signMode !== SIGN_MODE.DIRECT) {
throw new Error('not a direct general offline signer');
}

Expand Down
4 changes: 2 additions & 2 deletions networks/cosmos/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class AminoGeneralOfflineSigner implements IAminoGeneralOfflineSigner {

}

readonly signMode: string = SIGN_MODE.SIGN_MODE_LEGACY_AMINO_JSON;
readonly signMode: string = SIGN_MODE.AMINO;
getAccounts(): Promise<readonly AccountData[]> {
return this.offlineSigner.getAccounts();
}
Expand All @@ -133,7 +133,7 @@ export class DirectGeneralOfflineSigner implements IDirectGeneralOfflineSigner {

}

readonly signMode: string = SIGN_MODE.SIGN_MODE_DIRECT;
readonly signMode: string = SIGN_MODE.DIRECT;
getAccounts(): Promise<readonly AccountData[]> {
return this.offlineSigner.getAccounts();
}
Expand Down
4 changes: 2 additions & 2 deletions networks/injective/src/signing-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class InjSigningClient extends SigningClient {
let signers;

switch (this.offlineSigner.signMode) {
case SIGN_MODE.SIGN_MODE_DIRECT:
case SIGN_MODE.DIRECT:
signers = await DirectSigner.fromWalletToSigners(
this.offlineSigner as IDirectGeneralOfflineSigner,
this.encoders,
Expand All @@ -42,7 +42,7 @@ export class InjSigningClient extends SigningClient {
)
break;

case SIGN_MODE.SIGN_MODE_LEGACY_AMINO_JSON:
case SIGN_MODE.AMINO:
signers = await AminoSigner.fromWalletToSigners(
this.offlineSigner as IAminoGeneralOfflineSigner,
this.encoders,
Expand Down
11 changes: 8 additions & 3 deletions packages/types/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ export class BaseSigner {
* SIGN_MODE for IGeneralOfflineSigner
*/
export const SIGN_MODE = {
SIGN_MODE_DIRECT: 'SIGN_MODE_DIRECT',
SIGN_MODE_LEGACY_AMINO_JSON: 'SIGN_MODE_LEGACY_AMINO_JSON',
SIGN_MODE_EIP712_V2: 'SIGN_MODE_EIP712_V2',
/**
* SIGN_MODE for (cosmos_)direct
*/
DIRECT: 'direct',
/**
* SIGN_MODE for (cosmos_)amino
*/
AMINO: 'amino',
};

/**
Expand Down

0 comments on commit 817d034

Please sign in to comment.