Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #33 from Othent/feat--deployWarpContractFromTx
Browse files Browse the repository at this point in the history
Feat  deploy warp contract from tx
  • Loading branch information
LorimerJenkins authored Aug 27, 2023
2 parents 73bf362 + ce35089 commit 06514f4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "othent",
"version": "1.0.641",
"version": "1.0.642",
"description": "Merging Web2 to Web3 user logins with a familiar and simple interface",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
45 changes: 44 additions & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import {
DecryptDataReturnProps,
DeployWarpContractProps,
DeployWarpContractReturnProps,
DeployWarpContractFromTxProps,
DeployWarpContractFromTxReturnProps
} from "../types/index.js";


Expand Down Expand Up @@ -735,6 +737,46 @@ export async function Othent(params: useOthentProps): Promise<useOthentReturnPro



// Deploy a Warp contract from transaction
async function deployWarpContractFromTx(params: DeployWarpContractFromTxProps): Promise<DeployWarpContractFromTxReturnProps> {
params.tags ??= []
params.testNet ??= false
let networkType
if (params.testNet === true) {
networkType = 'testNet'
} else {
networkType = 'mainNet'
}
const auth0 = await getAuth0Client();
const authParams = { transaction_input: JSON.stringify({
othentFunction: 'deployWarpContractFromTx',
srcTxId: params.srcTxId,

}) }
const accessToken = await getTokenSilently(auth0, authParams)
const JWT = accessToken.id_token
return await axios({
method: 'POST',
url: 'https://server.othent.io/deploy-warp-contract-from-tx',
data: {
srcTxId: params.srcTxId,
contractState: params.state,
JWT: JWT,
tags: params.tags,
network: networkType
}
})
.then(response => {
return response.data;
})
.catch(error => {
console.log(error.response.data);
throw error;
});
}






Expand All @@ -759,7 +801,8 @@ export async function Othent(params: useOthentProps): Promise<useOthentReturnPro
verifyBundlrData,
encryptData,
decryptData,
deployWarpContract
deployWarpContract,
deployWarpContractFromTx
};
})
.catch((error) => {
Expand Down
18 changes: 17 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface useOthentReturnProps {
readCustomContract(params: readCustomContractProps): Promise<readCustomContractReturnProps>,
verifyArweaveData(params: verifyArweaveDataProps): Promise<verifyArweaveDataReturnProps>,
verifyBundlrData(params: verifyBundlrDataProps): Promise<verifyBundlrDataReturnProps>,
deployWarpContract(params: DeployWarpContractProps): Promise<DeployWarpContractReturnProps>,
deployWarpContractFromTx(params: DeployWarpContractFromTxProps): Promise<DeployWarpContractFromTxReturnProps>
}


Expand Down Expand Up @@ -375,7 +377,7 @@ export interface DecryptDataReturnProps {



// Verify bundlr data
// Deploy warp contract
export interface DeployWarpContractProps {
contractSrc: string,
state: object,
Expand All @@ -389,6 +391,20 @@ export interface DeployWarpContractReturnProps {



// Deploy warp contract from tx
export interface DeployWarpContractFromTxProps {
srcTxId: string,
state: object,
tags?: { name: string, value: string }[],
testNet?: boolean
}
export interface DeployWarpContractFromTxReturnProps {
contractTxId: string;
srcTxId?: string;
}






Expand Down

0 comments on commit 06514f4

Please sign in to comment.