Skip to content

Commit 992b288

Browse files
committed
naas client test
1 parent bd4a940 commit 992b288

6 files changed

Lines changed: 195 additions & 9 deletions

File tree

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules/
2-
src
32
# Ignore files with sensitive environment variables
43
.env
54
.env.test

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
2-
"name": "onec-sdk",
3-
"version": "0.1.5",
4-
"description": "Onec Client NPM Package",
5-
"main": "./dist/onec-client.bundle.js",
2+
"name": "ceno-test",
3+
"version": "0.3.1",
4+
"description": "ceno Client NPM Package",
5+
"main": "./dist/onec-sdk.bundle.js",
6+
"exports": {
7+
".": "./dist/onec-sdk.bundle.js",
8+
"./client": "./src/client/onec-client.js"
9+
},
610
"scripts": {
711
"test": "echo \"Error: no test specified\" && exit 1",
812
"build": "webpack --mode=development",

src/client/onec-client.js

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
var constants = require("../constants");
2+
var axios = require('axios');
3+
4+
const ONEC_AUTH_USERS_BASE_URL = constants.ONEC_NAAS_BASE_URL
5+
6+
class naas {
7+
constructor(api_key) {
8+
this.api_key = api_key;
9+
}
10+
11+
async mintNFT(data) {
12+
const url = `${ONEC_AUTH_USERS_BASE_URL}mintNFT/`
13+
const resData = await axios.post(url, data, {
14+
headers: {
15+
"Content-Type": "application/json",
16+
"NAAS-APIKEY": this.api_key
17+
}
18+
})
19+
.then((response) => {
20+
return response.data;
21+
})
22+
23+
return resData
24+
}
25+
26+
async mintRefNFT(data) {
27+
const url = `${ONEC_AUTH_USERS_BASE_URL}mintRefNFT/`
28+
const resData = await axios.post(url, data, {
29+
headers: {
30+
"Content-Type": "application/json",
31+
"NAAS-APIKEY": this.api_key
32+
}
33+
})
34+
.then((response) => {
35+
return response.data;
36+
})
37+
38+
return resData
39+
}
40+
41+
async checkMintStatus(txn_tracker) {
42+
const url = `${ONEC_AUTH_USERS_BASE_URL}checkMintStatus/${txn_tracker}/`
43+
const resData = await axios.get(url, {
44+
headers: {
45+
"Content-Type": "application/json",
46+
"NAAS-APIKEY": this.api_key
47+
}
48+
})
49+
.then((response) => {
50+
return response.data;
51+
})
52+
53+
return resData
54+
}
55+
56+
async fetchTokenID(nft_id) {
57+
const url = `${ONEC_AUTH_USERS_BASE_URL}fetchTokenId/${nft_id}/`
58+
const resData = await axios.get(url, {
59+
headers: {
60+
"Content-Type": "application/json",
61+
"NAAS-APIKEY": this.api_key
62+
}
63+
})
64+
.then((response) => {
65+
return response.data;
66+
})
67+
68+
return resData
69+
}
70+
71+
async fetchRefTokenID(refnft_id) {
72+
const url = `${ONEC_AUTH_USERS_BASE_URL}fetchRefTokenId/${refnft_id}/`
73+
const resData = await axios.get(url, {
74+
headers: {
75+
"Content-Type": "application/json",
76+
"NAAS-APIKEY": this.api_key
77+
}
78+
})
79+
.then((response) => {
80+
return response.data;
81+
})
82+
83+
return resData
84+
}
85+
86+
async getTokenMetadataHash(token_id) {
87+
const url = `${ONEC_AUTH_USERS_BASE_URL}getTokenMetadataHash/${token_id}/`
88+
const resData = await axios.get(url, {
89+
headers: {
90+
"Content-Type": "application/json",
91+
"NAAS-APIKEY": this.api_key
92+
}
93+
})
94+
.then((response) => {
95+
return response.data;
96+
})
97+
98+
return resData
99+
}
100+
101+
async getRefNFTs(parent_id) {
102+
const url = `${ONEC_AUTH_USERS_BASE_URL}getRefNFTs/${parent_id}/`
103+
const resData = await axios.get(url, {
104+
headers: {
105+
"Content-Type": "application/json",
106+
"NAAS-APIKEY": this.api_key
107+
}
108+
})
109+
.then((response) => {
110+
return response.data;
111+
})
112+
113+
return resData
114+
}
115+
116+
async getIpfsFiles() {
117+
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsFile/`
118+
const resData = await axios.get(url, {
119+
headers: {
120+
"Content-Type": "application/json",
121+
"NAAS-APIKEY": this.api_key
122+
}
123+
})
124+
.then((response) => {
125+
return response.data;
126+
})
127+
128+
return resData
129+
}
130+
131+
async uploadIpfsFiles(files) {
132+
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsFile/`
133+
const resData = await axios.post(url, files, {
134+
headers: {
135+
"Content-Type": "multipart/form-data",
136+
"NAAS-APIKEY": this.api_key
137+
}
138+
})
139+
.then((response) => {
140+
return response.data;
141+
})
142+
143+
return resData
144+
}
145+
146+
async getIpfsMetaData() {
147+
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsMetaData/`
148+
const resData = await axios.get(url, {
149+
headers: {
150+
"Content-Type": "application/json",
151+
"NAAS-APIKEY": this.api_key
152+
}
153+
})
154+
.then((response) => {
155+
return response.data;
156+
})
157+
158+
return resData
159+
}
160+
161+
async uploadIpfsMetaData(data) {
162+
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsMetaData/`
163+
const resData = await axios.post(url, data, {
164+
headers: {
165+
"Content-Type": "application/json",
166+
"NAAS-APIKEY": this.api_key
167+
}
168+
})
169+
.then((response) => {
170+
return response.data;
171+
})
172+
173+
return resData
174+
}
175+
176+
verifyKey() {
177+
return this.api_key
178+
}
179+
}
180+
181+
module.exports = {
182+
naas
183+
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withWalletConnect, withMetamask } from "./AuthUtils/WalletAuth";
1+
import { withWalletConnect, withMetamask } from "./web/AuthUtils/WalletAuth";
22

33
const auth = {
44
withMetamask,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import MetaMaskOnboarding from '@metamask/onboarding';
22
import WalletConnect from "@walletconnect/client";
33
import QRCodeModal from "@walletconnect/qrcode-modal";
44
import axios, { AxiosResponse, AxiosError } from 'axios';
5-
import * as constants from "../constants"
5+
import * as constants from "../../constants"
66

77
let ONEC_AUTH_USERS_BASE_URL = constants.ONEC_NAAS_BASE_URL;
88
let _mmConnector = null;

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module.exports = {
66
output: {
77
path: path.resolve(__dirname, 'dist'),
88
clean: true,
9-
filename: 'onec-client.bundle.js',
9+
filename: 'onec-sdk.bundle.js',
1010
library: {
11-
name: 'onec',
11+
name: 'onec-sdk',
1212
type: 'umd',
1313
umdNamedDefine: true,
1414
export: 'default',

0 commit comments

Comments
 (0)