-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into id-802-150
- Loading branch information
Showing
176 changed files
with
2,006 additions
and
2,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...blockchain/web3-private-service/web3-private/bitcoin-web3-private/bitcoin-web3-private.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { BLOCKCHAIN_NAME, BlockchainName } from 'src/core/blockchain/models/blockchain-name'; | ||
import { BasicTransactionOptions } from 'src/core/blockchain/web3-private-service/web3-private/models/basic-transaction-options'; | ||
import { BitcoinWeb3Pure } from 'src/core/blockchain/web3-pure/typed-web3-pure/bitcoin-web3-pure'; | ||
import { BitcoinWalletProviderCore } from 'src/core/sdk/models/wallet-provider'; | ||
import { OnChainStatusManager } from 'src/features/on-chain/status-manager/on-chain-status-manager'; | ||
|
||
import { Web3Private } from '../web3-private'; | ||
|
||
export class BitcoinWeb3Private extends Web3Private { | ||
protected readonly Web3Pure = BitcoinWeb3Pure; | ||
|
||
public getBlockchainName(): Promise<BlockchainName> { | ||
return Promise.resolve(BLOCKCHAIN_NAME.BITCOIN); | ||
} | ||
|
||
public async transfer( | ||
recipient: string, | ||
amount: string, | ||
memo?: string, | ||
options?: BasicTransactionOptions | ||
): Promise<string> { | ||
const hashPromise = new Promise<string>((resolve, reject) => { | ||
this.wallet.core.request( | ||
{ | ||
method: 'transfer', | ||
params: [ | ||
{ | ||
feeRate: 10, | ||
from: this.wallet.address, | ||
recipient, | ||
amount: { | ||
amount, | ||
decimals: 8 | ||
}, | ||
...(memo && { memo }) | ||
} | ||
] | ||
}, | ||
(error, txHash) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
options?.onTransactionHash?.(txHash); | ||
resolve(txHash); | ||
} | ||
} | ||
); | ||
}); | ||
try { | ||
const hash = await hashPromise; | ||
if (typeof hash === 'string') { | ||
const statusData = await OnChainStatusManager.getBitcoinTransaction(hash); | ||
return statusData.hash!; | ||
} | ||
throw new Error(); | ||
} catch { | ||
throw new Error('Failed to transfer funds'); | ||
} | ||
} | ||
|
||
constructor(private readonly wallet: BitcoinWalletProviderCore) { | ||
super(wallet.address); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...n/web3-private-service/web3-private/bitcoin-web3-private/models/bitcoin-encoded-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface BitcoinEncodedConfig { | ||
data?: string; | ||
to: string; | ||
value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.