Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Check if version changed
run: |
npm install -g pnpm
pnpm install

for dir in packages/*/ packages/networks/*/; do
if [ -d "$dir" ] && [ "$(basename "$dir")" != "boilerplate" ]; then
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MultipleChain standard for JavaScript

## Introduction

MultipleChain aims for easy access by simplifying the complex structure of many blockchains. For example, each blockchain network has a different structure for transfer initiation or transaction data. You may need to learn new things from scratch for each blockchain network. This is necessary if you want to go into detail. But if you just want to get to the basics. MultipleChain will make your work much easier. In many different programming languages.

#### 📚 [Documentation](https://multiplechain.gitbook.io/multiplechain-docs)
12 changes: 0 additions & 12 deletions index.example.html

This file was deleted.

7 changes: 7 additions & 0 deletions packages/networks/bitcoin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MultipleChain standard for JavaScript

## Introduction

MultipleChain aims for easy access by simplifying the complex structure of many blockchains. For example, each blockchain network has a different structure for transfer initiation or transaction data. You may need to learn new things from scratch for each blockchain network. This is necessary if you want to go into detail. But if you just want to get to the basics. MultipleChain will make your work much easier. In many different programming languages.

#### 📚 [Documentation](https://multiplechain.gitbook.io/multiplechain-docs)
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
}

const wallet = new Bitcoin.browser.Wallet(adapter)
const adapterProvider = await wallet.connect(provider, {
const adapterProvider = await wallet.connect({
projectId: '113d9f5689edd84ff230c2a6d679c80c'
})

Expand Down
14 changes: 12 additions & 2 deletions packages/networks/bitcoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
"types": "./dist/browser/index.d.ts"
}
},
"typesVersions": {
"*": {
"node": [
"./dist/index.d.ts"
],
"browser": [
"./dist/browser/index.d.ts"
]
}
},
"files": [
"dist",
"README.md",
Expand Down Expand Up @@ -62,8 +72,8 @@
"url": "https://github.com/MultipleChain/js/issues"
},
"dependencies": {
"@multiplechain/types": "^0.1.56",
"@multiplechain/utils": "^0.1.20",
"@multiplechain/types": "^0.1.63",
"@multiplechain/utils": "^0.1.21",
"axios": "^1.6.8",
"bitcore-lib": "^10.0.28",
"sats-connect": "^2.3.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/networks/bitcoin/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions packages/networks/bitcoin/src/assets/Coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import axios from 'axios'
import { Provider } from '../services/Provider.ts'
import { fromSatoshi, toSatoshi } from '../utils.ts'
import { Transaction, Script, Address } from 'bitcore-lib'
import { ErrorTypeEnum, type CoinInterface } from '@multiplechain/types'
import { CoinTransactionSigner } from '../services/TransactionSigner.ts'
import { TransactionSigner } from '../services/TransactionSigner.ts'
import {
ErrorTypeEnum,
type CoinInterface,
type TransferAmount,
type WalletAddress
} from '@multiplechain/types'

export class Coin implements CoinInterface {
export class Coin implements CoinInterface<TransactionSigner> {
/**
* Blockchain network provider
*/
Expand Down Expand Up @@ -40,10 +45,10 @@ export class Coin implements CoinInterface {
}

/**
* @param {string} owner Wallet address
* @param {WalletAddress} owner Wallet address
* @returns {Promise<number>} Wallet balance as currency of COIN
*/
async getBalance(owner: string): Promise<number> {
async getBalance(owner: WalletAddress): Promise<number> {
const addressStatsApi = this.provider.createEndpoint('address/' + owner)
const addressStats = await axios.get(addressStatsApi).then((res) => res.data)
const balanceSat =
Expand All @@ -52,16 +57,16 @@ export class Coin implements CoinInterface {
}

/**
* @param {string} sender Sender wallet address
* @param {string} receiver Receiver wallet address
* @param {number} amount Amount of assets that will be transferred
* @param {WalletAddress} sender Sender wallet address
* @param {WalletAddress} receiver Receiver wallet address
* @param {TransferAmount} amount Amount of assets that will be transferred
* @returns {Promise<TransactionSigner>} Transaction signer
*/
async transfer(
sender: string,
receiver: string,
amount: number
): Promise<CoinTransactionSigner> {
sender: WalletAddress,
receiver: WalletAddress,
amount: TransferAmount
): Promise<TransactionSigner> {
if (amount < 0) {
throw new Error(ErrorTypeEnum.INVALID_AMOUNT)
}
Expand Down Expand Up @@ -99,7 +104,7 @@ export class Coin implements CoinInterface {
transaction.change(sender)
transaction.to(receiver, satoshiToSend)

return new CoinTransactionSigner({
return new TransactionSigner({
sender,
receiver,
amount: satoshiToSend,
Expand Down
59 changes: 0 additions & 59 deletions packages/networks/bitcoin/src/assets/Contract.ts

This file was deleted.

96 changes: 0 additions & 96 deletions packages/networks/bitcoin/src/assets/NFT.ts

This file was deleted.

Loading