Skip to content

Commit

Permalink
Merge pull request #131 from ainblockchain/feature/hyeonwoong/ain-wal…
Browse files Browse the repository at this point in the history
…let-signer

Add ainWalletSigner
  • Loading branch information
woomurf authored Aug 22, 2023
2 parents e475b5b + 6ebb22b commit 4cd6c32
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Wallet from './wallet';
import Network from './net';
import EventManager from './event-manager';
import HomomorphicEncryption from './he';
import { DefaultSigner, Signer } from "./signer";
import { DefaultSigner, Signer } from "./signer/signer";

export default class Ain {
public axiosConfig: AxiosRequestConfig | undefined;
Expand Down
20 changes: 20 additions & 0 deletions src/signer/ain-wallet-signer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Signer } from "./signer";

export class AinWalletSigner implements Signer {
private ainetwork: Signer;

constructor() {
if (window.ainetwork) {
this.ainetwork = window.ainetwork;
} else {
throw new Error("Not found ain wallet object");
}
}
getAddress(address?: string): string {
return this.ainetwork.getAddress(address);
}

signMessage(message: any, address?: string): Promise<string> | string {
return this.ainetwork.signMessage(message, address);
}
}
2 changes: 1 addition & 1 deletion src/signer.ts → src/signer/signer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Wallet from "./wallet";
import Wallet from "../wallet";

/**
* Signer takes responsibility to sign message and transaction.
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AxiosRequestConfig } from "axios";
import {Signer} from "./signer/signer";

declare global {
interface Window {
ainetwork: Signer;
}
}

export interface Account {
address: string;
Expand Down

0 comments on commit 4cd6c32

Please sign in to comment.