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

[Bitcore] Solana Support #3829

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
749648b
Adding ability to derive solona address
micahriggan Jan 27, 2024
be7909c
the addresses are only able to be derived from xpriv and should alway…
micahriggan Jan 28, 2024
4b828c3
remove import of tweetnacl
micahriggan Jan 28, 2024
4cd688f
cleanup
micahriggan Jan 28, 2024
0ce550e
solana module
leolambo Sep 17, 2024
2ff39d3
Merge branch 'master' of https://github.com/bitpay/bitcore into solan…
leolambo Sep 17, 2024
c1ff7a1
Merge branch 'feature/solana-derive' of https://github.com/micahrigga…
leolambo Dec 9, 2024
432e40f
update solana web3js
leolambo Dec 9, 2024
d118eba
feedback from PR #3692
leolambo Dec 9, 2024
87a4343
sol support BWS, BWC, CWC
leolambo Dec 10, 2024
141b798
sol validation
leolambo Dec 10, 2024
0e2f36d
solana transaction creation support
leolambo Dec 12, 2024
b576a26
solana transaction transform
leolambo Dec 13, 2024
425d836
cleanup
leolambo Dec 13, 2024
7f70eb4
Solana ChainService update
leolambo Dec 13, 2024
1e6017e
Merge branch 'master' of https://github.com/bitpay/bitcore into solan…
leolambo Dec 13, 2024
d317b8f
update package.json
leolambo Dec 13, 2024
8c114df
Solana integration tests
leolambo Dec 13, 2024
b73d396
handle websocket error
leolambo Dec 13, 2024
fee94a2
Merge branch 'solana-bws' of https://github.com/leolambo/bitcore into…
leolambo Dec 13, 2024
f64431e
cleanup
leolambo Dec 14, 2024
2d46e22
convert privateKey
leolambo Dec 14, 2024
9389cef
fix bson import
leolambo Dec 15, 2024
e76daa5
use ObjectId instead of ObjectID
leolambo Dec 15, 2024
4d06192
dedupe packag-lock.json
leolambo Dec 15, 2024
c17e8ac
cleanup
leolambo Dec 16, 2024
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
26 changes: 16 additions & 10 deletions packages/bitcore-client/src/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Bcrypt from 'bcrypt';
import { BitcoreLib, BitcoreLibCash, BitcoreLibDoge, BitcoreLibLtc, Deriver, ethers, Transactions, Web3, xrpl } from 'crypto-wallet-core';
import { BitcoreLib, BitcoreLibCash, BitcoreLibDoge, BitcoreLibLtc, Deriver, ethers, SolWeb3, Transactions, Web3, xrpl } from 'crypto-wallet-core';
import 'source-map-support/register';
import { Client } from './client';
import { Encryption } from './encryption';
Expand All @@ -18,7 +18,8 @@ const chainLibs = {
ARB: { Web3, ethers },
BASE: { Web3, ethers },
OP: { Web3, ethers },
XRP: xrpl
XRP: xrpl,
SOL: SolWeb3
};

export interface KeyImport {
Expand Down Expand Up @@ -196,7 +197,7 @@ export class Wallet {
let alreadyExists;
try {
alreadyExists = await this.loadWallet({ storage, name, storageType });
} catch (err) {}
} catch (err) { }
if (alreadyExists) {
throw new Error('Wallet already exists');
}
Expand Down Expand Up @@ -285,6 +286,10 @@ export class Wallet {
return ['ETH', 'MATIC', 'ARB', 'OP', 'BASE'].includes(this.chain?.toUpperCase());
}

isSvmChain() {
return ['SOL'].includes(this.chain?.toUpperCase());
}

lock() {
this.unlocked = undefined;
return this;
Expand All @@ -301,6 +306,7 @@ export class Wallet {
const encMasterKey = this.masterKey;
const masterKeyStr = await Encryption.decryptPrivateKey(encMasterKey, this.pubKey, encryptionKey);
masterKey = JSON.parse(masterKeyStr);
masterKey = masterKey?.privateKey || masterKey;
}
this.unlocked = {
encryptionKey,
Expand Down Expand Up @@ -454,7 +460,7 @@ export class Wallet {
if (!this.tokens) {
return;
}
this.tokens = this.tokens.filter(tok =>
this.tokens = this.tokens.filter(tok =>
(tok.name && tok.name !== tokenName) ||
/* legacy object */ (!tok.name && tok.symbol !== tokenName)
);
Expand Down Expand Up @@ -785,7 +791,7 @@ export class Wallet {
console.log(`Bumping fee rate to ${params.feeRate} sats/byte`);
}

// EVM chains
// EVM chains
} else {
const { nonce, gasLimit, gasPrice, to, data, value, chainId, type } = existingTx;
// converting gasLimit and value with toString avoids a bigNumber warning
Expand All @@ -796,7 +802,7 @@ export class Wallet {
params.chainId = chainId;
params.type = type;
params.recipients = [{ address: to, amount: value.toString() }];

// TODO fix type2 support
if (false && existingTx.type === 2) {
if (feeRate) {
Expand All @@ -806,15 +812,15 @@ export class Wallet {
// params.maxGasFee = (await wallet.getNetworkFee({ target: feeTarget })).feerate;
// console.log(`Bumping max gas price to ${Web3.utils.fromWei(params.maxGasFee.toString(), 'gwei')} gwei`);
}
if (feePriority) {
if (feePriority) {
params.maxPriorityFee = Web3.utils.toWei(feePriority.toString(), 'gwei');
} else {
// TODO placeholder until for type2 support is merged in another PR
// params.maxPriorityFee = existingTx.maxPriorityFeePerGas;
// console.log(`Bumping max priority fee to ${Web3.utils.fromWei(params.maxPriorityFee.toString(), 'gwei')} gwei`);
}

// type 0
// type 0
} else {
if (feeRate) {
params.gasPrice = Web3.utils.toWei(feeRate.toString(), 'gwei');
Expand All @@ -823,7 +829,7 @@ export class Wallet {
console.log(`Bumping gas price to ${Web3.utils.fromWei(params.gasPrice.toString(), 'gwei')} gwei`);
}
}

}

const tx: string = await this.newTx(params);
Expand Down Expand Up @@ -862,7 +868,7 @@ export const AddressTypes = {
// witnesspubkeyhash
witnesspubkeyhash: 'witnesspubkeyhash',
p2wpkh: 'witnesspubkeyhash',

// taproot
taproot: 'taproot',
p2tr: 'taproot'
Expand Down
Loading