Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: make Clover's instance interface to be matched with @solana/web3 #963

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion wallets/provider-clover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"bs58": "^5.0.0",
"rango-types": "^0.1.74"
},
"peerDependencies": {
"@solana/web3.js": "^1.94.0"
},
"publishConfig": {
"access": "public"
}
}
}
18 changes: 17 additions & 1 deletion wallets/provider-clover/src/signer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SignerFactory } from 'rango-types';

import { getNetworkInstance, Networks } from '@rango-dev/wallets-shared';
import { PublicKey } from '@solana/web3.js';
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';

import { CustomSolanaSigner } from './solana-signer.js';
Expand All @@ -9,10 +10,25 @@ export default async function getSigners(
provider: any
): Promise<SignerFactory> {
const ethProvider = getNetworkInstance(provider, Networks.ETHEREUM);
//
const solProvider = getNetworkInstance(provider, Networks.SOLANA);
const solAccountAddress = await solProvider.getAccount();
const proxiedSolProvider = new Proxy(solProvider, {
get(target, prop, rec) {
if (prop === 'publicKey') {
return new PublicKey(solAccountAddress);
}

return Reflect.get(target, prop, rec);
},
});

const signers = new DefaultSignerFactory();
const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');
signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));
signers.registerSigner(TxType.SOLANA, new CustomSolanaSigner(solProvider));
signers.registerSigner(
TxType.SOLANA,
new CustomSolanaSigner(proxiedSolProvider)
);
return signers;
}