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

feat: implement required calls to inscribe service for BRC20 transfer #182

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
70c39a0
feat: implement required calls to inscribe service
victorkirov Jul 20, 2023
6518ca7
feat: do full BRC-20 transfer in 1 call
victorkirov Jul 24, 2023
0fdba23
fix: import/export names
victorkirov Jul 24, 2023
2eb8577
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Jul 24, 2023
e37a7cb
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Jul 24, 2023
b9fa9a5
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Jul 25, 2023
9042413
fix: fee calc and utxo select
victorkirov Jul 25, 2023
2338ee2
fix: type issue
victorkirov Jul 25, 2023
119d0c5
feat: Add all brc-20 api calls
victorkirov Jul 28, 2023
b9ba6be
feat: implement 1 step transfer generator
victorkirov Jul 28, 2023
bcf6606
chore: add btc functions for brc-20 transfer
victorkirov Jul 28, 2023
20be088
chore: add brc-20 tests
victorkirov Jul 31, 2023
6ea85ac
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Jul 31, 2023
3922c4a
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Aug 1, 2023
bded70d
oopsie
victorkirov Aug 1, 2023
1c82cf8
feat: added mint functions and exponential backoff for retries
victorkirov Aug 1, 2023
dea9238
chore: add unit tests for mint
victorkirov Aug 1, 2023
dba4ff4
Merge branch 'develop' of https://github.com/secretkeylabs/xverse-cor…
victorkirov Aug 1, 2023
1b2dc62
fix: make arguments an object instead of multiple arguments
victorkirov Aug 2, 2023
ed61b5e
fix: fee calc resulting in fee higher than input
victorkirov Aug 2, 2023
ef77162
fix: tests
victorkirov Aug 2, 2023
c843127
Add missing return types and add comment
victorkirov Aug 4, 2023
194ca52
Add transfer finalize call
victorkirov Aug 4, 2023
a206594
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Aug 4, 2023
a7fe12b
AAdd finalize call to transfer script and fix tests
victorkirov Aug 4, 2023
ecfa418
Merge branch 'develop' into victor/eng-2391-implement-1-step-brc-20-t…
victorkirov Aug 7, 2023
902b245
Merge branch 'develop' of https://github.com/secretkeylabs/xverse-cor…
victorkirov Aug 7, 2023
de4fe55
fix issues form merge
victorkirov Aug 7, 2023
d22ceee
fix: tests
victorkirov Aug 7, 2023
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
163 changes: 163 additions & 0 deletions api/xverseInscribe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import axios from 'axios';

import {
Brc20CostEstimateRequest,
Brc20CostEstimateResponse,
Brc20CreateOrderRequest,
Brc20CreateOrderResponse,
Brc20ExecuteOrderRequest,
Brc20ExecuteOrderResponse,
NetworkType,
} from 'types';

import { XVERSE_INSCRIBE_URL } from '../constant';

const apiClient = axios.create({
baseURL: XVERSE_INSCRIBE_URL,
});

const getBrc20TransferFees = async (
tick: string,
amount: number,
revealAddress: string,
feeRate: number,
inscriptionValue?: number,
): Promise<Brc20CostEstimateResponse> => {
const requestBody: Brc20CostEstimateRequest = {
operation: 'transfer',
tick,
amount,
revealAddress,
feeRate,
inscriptionValue,
};
const response = await apiClient.post<Brc20CostEstimateResponse>('/v1/brc20/cost-estimate', requestBody);
return response.data;
teebszet marked this conversation as resolved.
Show resolved Hide resolved
};

const createBrc20TransferOrder = async (
tick: string,
amount: number,
revealAddress: string,
feeRate: number,
network: NetworkType,
inscriptionValue?: number,
): Promise<Brc20CreateOrderResponse> => {
const requestBody: Brc20CreateOrderRequest = {
operation: 'transfer',
tick,
amount,
revealAddress,
feeRate,
network,
inscriptionValue,
};
const response = await apiClient.post<Brc20CreateOrderResponse>('/v1/brc20/place-order', requestBody);
return response.data;
};

const getBrc20MintFees = async (
tick: string,
amount: number,
revealAddress: string,
feeRate: number,
inscriptionValue?: number,
): Promise<Brc20CostEstimateResponse> => {
const requestBody: Brc20CostEstimateRequest = {
operation: 'mint',
tick,
amount,
revealAddress,
feeRate,
inscriptionValue,
};
const response = await apiClient.post<Brc20CostEstimateResponse>('/v1/brc20/cost-estimate', requestBody);
return response.data;
};

const createBrc20MintOrder = async (
tick: string,
amount: number,
revealAddress: string,
feeRate: number,
network: NetworkType,
inscriptionValue?: number,
): Promise<Brc20CreateOrderResponse> => {
const requestBody: Brc20CreateOrderRequest = {
operation: 'mint',
tick,
amount,
revealAddress,
feeRate,
network,
inscriptionValue,
};
const response = await apiClient.post<Brc20CreateOrderResponse>('/v1/brc20/place-order', requestBody);
return response.data;
};

const getBrc20DeployFees = async (
tick: string,
max: number,
limit: number,
revealAddress: string,
feeRate: number,
inscriptionValue?: number,
): Promise<Brc20CostEstimateResponse> => {
const requestBody: Brc20CostEstimateRequest = {
operation: 'deploy',
tick,
lim: limit,
max: max,
revealAddress,
feeRate,
inscriptionValue,
};
const response = await apiClient.post<Brc20CostEstimateResponse>('/v1/brc20/cost-estimate', requestBody);
return response.data;
};

const createBrc20DeployOrder = async (
tick: string,
max: number,
limit: number,
revealAddress: string,
feeRate: number,
network: NetworkType,
inscriptionValue?: number,
): Promise<Brc20CreateOrderResponse> => {
const requestBody: Brc20CreateOrderRequest = {
operation: 'deploy',
tick,
lim: limit,
max: max,
revealAddress,
feeRate,
network,
inscriptionValue,
};
const response = await apiClient.post<Brc20CreateOrderResponse>('/v1/brc20/place-order', requestBody);
return response.data;
};

const executeBrc20Order = async (
commitAddress: string,
commitTransactionHex: string,
): Promise<Brc20ExecuteOrderResponse> => {
const requestBody: Brc20ExecuteOrderRequest = {
commitAddress,
commitTransactionHex,
};
const response = await apiClient.post<Brc20ExecuteOrderResponse>('/v1/brc20/execute-order', requestBody);
return response.data;
};

export default {
getBrc20TransferFees,
createBrc20TransferOrder,
getBrc20MintFees,
createBrc20MintOrder,
getBrc20DeployFees,
createBrc20DeployOrder,
executeBrc20Order,
};
2 changes: 2 additions & 0 deletions constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const NFT_BASE_URI = 'https://stacks.gamma.io/api/v1/collections';

export const XVERSE_API_BASE_URL = 'https://api.xverse.app';

export const XVERSE_INSCRIBE_URL = 'https://inscribe.xverse.app';

export const XVERSE_SPONSOR_URL = 'https://sponsor.xverse.app';

export const GAIA_HUB_URL = 'https://hub.blockstack.org';
Expand Down
Loading
Loading