Skip to content

Commit

Permalink
Merge pull request #160 from VWBL/update-readme
Browse files Browse the repository at this point in the history
【XRPL対応】README更新
  • Loading branch information
passion0102 authored Aug 31, 2024
2 parents bf69c9d + e4426e3 commit aa3815e
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 16 deletions.
157 changes: 143 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ https://docs.vwbl-protocol.org
### install

##### Using NPM
`npm install vwbl-sdk`

`npm install vwbl-sdk vwbl-core`

_for XRPL_

`npm install vwbl-sdk-xrpl vwbl-core`

##### Using Yarn
`yarn add vwbl-sdk`

`yarn add vwbl-sdk vwbl-core`

_for XRPL_

`yarn add vwbl-sdk-xrpl vwbl-core`

### Build

`npm run build:all`

### Arcihtecture Overview
| Package | Version | License | Description |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [vwbl-sdk](./packages/evm/) | [![npm version](https://badge.fury.io/js/vwbl-sdk.svg)](https://badge.fury.io/js/vwbl-sdk) | ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) | VWBL SDK for EVM compatible chain |
| [vwbl-core](./packages/core/) | [![npm version](https://badge.fury.io/js/vwbl-core.svg)](https://badge.fury.io/js/vwbl-core) | ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) | VWBL core tools for sub-package |

| Package | Version | License | Description |
| --------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | --------------------------------- |
| [vwbl-sdk](./packages/evm/) | [![npm version](https://badge.fury.io/js/vwbl-sdk.svg)](https://badge.fury.io/js/vwbl-sdk) | ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) | VWBL SDK for EVM compatible chain |
| [vwbl-core](./packages/core/) | [![npm version](https://badge.fury.io/js/vwbl-core.svg)](https://badge.fury.io/js/vwbl-core) | ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) | VWBL core tools for sub-package |
| [vwbl-sdk-xrpl](./packages/xrpl/) | [![npm version](https://badge.fury.io/js/vwbl-sdk-xrpl.svg)](https://badge.fury.io/js/vwbl-sdk-xrpl) | ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) | VWBL SDK for XRPL |

## api document

Expand All @@ -45,6 +58,27 @@ new VWBL({
});
```

_for XRPL_

```typescript
new VWBLXRPL({
xrplChainId: 1, // Mainnet:0 / Testnet:1 / Devnet:2
vwblNetworkUrl: "https://vwbl.network",
manageKeyType: ManageKeyType.VWBL_NETWORK_SERVER,
uploadContentType: UploadContentType.S3,
uploadMetadataType: UploadMetadataType.S3,
awsConfig: {
region: "ap-northeast-1",
idPoolId: "ap-northeast-1:...",
cloudFrontUrl: "https://xxx.cloudfront.net",
bucketName: {
metadata: "vwbl-metadata",
content: "vwbl-content",
},
},
});
```

Constructor Options

| name | required | type | description |
Expand All @@ -56,9 +90,9 @@ Constructor Options
| uploadContentType | flase | UploadContentType | where to upload content, you can choose from <br> S3 <br> IPFS <br> CUSTOM |
| uploadMetadataType | flase | UploadMetadataType | where to upload content, you can choose from <br> S3 <br> IPFS <br> CUSTOM |
| awsConfig | true if you choose to upload content or metadata to S3 | AWSConfig | AWSConfig \*1 |
| ipfsConfig | true if you choose to upload content or metadata to IPFS | IPFSConfig | IPFSConfig \*2 |
| ipfsConfig | true if you choose to upload content or metadata to IPFS | IPFSConfig | IPFSConfig \*2 |

AWSConfig(*1)
AWSConfig(\*1)

| name | required | type | description |
| ------------- | -------- | ----------------------------------- | --------------------------------------------------------- |
Expand All @@ -67,14 +101,17 @@ AWSConfig(*1)
| cloudFrontUrl | true | string | cloudFront url connect to s3 which is uploaded content |
| bucketName | true | {content: string, metadata: string} | bucketName of metadata and content, it's ok they are same |

IPFSConfig(\*2)

IPFSConfig(*2)
| name | required | type | description |
| --------- | -------- | ------ | -------------- |
| apiKey | true | string | API key |
| apiSecret | false | string | API secret key |

| name | required | type | description |
| ------------- | -------- | ----------------------------------- | --------------------------------------------------------- |
| apiKey | true | string | API key |
| apiSecret | false | string | API secret key |
|

## EVM (vwbl-sdk)

### sign to server

Signing is necessary before creating token or viewing contents.
Expand Down Expand Up @@ -108,10 +145,102 @@ Arguments
| uploadEncryptedFileCallback | true if uploadContentType is CUSTOM | UploadEncryptedFile | you can custom upload function |
| uploadThumbnailCallback | true if uploadContentType is CUSTOM | UploadThumbnail | you can custom upload function |
| uploadMetadataCallback | true if uploadMetadataType is CUSTOM | UploadMetadata | you can custom upload function |
| gasSettings | false | GasSettings | you can custom gas settings |
| gasSettings | false | GasSettings | you can custom gas settings |

### view contents ( get NFT metadata from given tokenId)

```typescript
const token = await vwbl.getTokenById(tokenId);
```

## XRPL (vwbl-sdk-xrpl)

### 1. generate mint tx

```typescript
const { mintTxJson } = await vwblXrpl.generateMintTokenTx(
// user's wallet address
walletAddress: string,
// 0~5000 (0.00% ~ 50.00%), see detail: https://xrpl.org/docs/references/protocol/transactions/types/nftokenmint
transferRoyalty: number,
// transferable NFT or not
isTransferable: boolean,
// burnable NFT or not
isBurnable: boolean
)
```

※ Then, you need to ask users to sign the transaction and get signed transaction hex

### 2. mint VWBL NFT and generate next tx object

```typescript
const { tokenId, emptyTxObject, paymentTxJson } =
await vwblXrpl.mintAndGenerateTx(
signedMintTx, // signed mint tx hex (signed by user)
walletAddress // user's wallet address
);
```

※ if VWBL NFT minting fee = 0, `paymentTxJson` is `undefined` and you can ignore
※ if VWBL NFT minting fee > 0, `emptyTxObject` is `undefined` and you can ignore

### (3. pay VWBL NFT minting fee) ※ NEED TO DO THIS if `paymentTxJson` was generated

```typescript
const { paymentTxHash, tokenId, emptyTxObject } = await vwblXrpl.payMintFee(
walletAddress, // user's wallet address
signedPaymentTx // signed `paymentTxJson` tx hex
);
```

### 4. create token & register key

```typescript
const { tokenId } = await vwblXrpl.createManagedToken(
// NFTokenID
tokenId,
// signed `emptyTxObject` hex
signedEmptyTx,
// user's public key
signerPublicKey,
// NFT name
name,
// NFT description
description,
// NFT file
plainFile,
// NFT thumbnail image
thumbnailImage,
// encryption logic (default: base64)
encryptLogic,
// `paymentTxHash` if minting fee is necessary
signedPaymentTxHash?,
// custom upload file function
uploadEncryptedFileCallback?,
// custom upload thumbnail function
uploadThumbnailCallback?,
// custom upload metadata function
uploadMetadataCallBack?
);
```
### view NFT contents
```typescript
const { emptyTxObject } = await vwblXrpl.generateTxForSigning(walletAddress);

// ... get user's signature for `emptyTxObject`

const {
id,
name,
description,
image,
mimeType,
encryptLogic,
ownDataBase64,
ownFiles,
fileName,
} = await vwblXrpl.extractMetadata(tokenId, signedEmptyTx, signerPublicKey);
```
4 changes: 2 additions & 2 deletions packages/xrpl/src/vwbl/VWBLXRPL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class VWBLXRPL {
if (mintFee === "0") {
const emptyTxObject = this.nft.generateEmptyTx(walletAddress);

return { tokenId, emptyTxObject };
return { tokenId, emptyTxObject, paymentTxJson: undefined };
}

const paymentTxJson = await this.nft.generatePaymentTx(
Expand All @@ -167,7 +167,7 @@ export class VWBLXRPL {
destination
);

return { tokenId, paymentTxJson };
return { tokenId, emptyTxObject: undefined, paymentTxJson };
};

mintAndGenerateTxForIPFS = async (
Expand Down

0 comments on commit aa3815e

Please sign in to comment.