emblem-vault-sdk 1.9.13 → 1.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +37 -14
- package/dist/index.js +23 -1
- package/dist/utils.js +14 -13
- package/docs/bundle.js +37 -14
- package/package.json +1 -1
- package/src/index.ts +16 -0
- package/src/utils.ts +16 -12
- package/tests/AllowedBells.test.ts +53 -0
- package/tests/AllowedBitcoinDeGods.test.ts +53 -0
- package/tests/AllowedBitcoinOrdinals.test.ts +46 -0
- package/tests/AllowedCounterparty.test.ts +45 -0
- package/tests/AllowedCursedOrdinals.test.ts +68 -0
- package/tests/AllowedEmbells.test.ts +12 -0
- package/tests/AllowedEmbels.test.ts +16 -0
- package/tests/AllowedEmblemOpen.test.ts +20 -0
- package/tests/AllowedEthscriptions.test.ts +39 -0
- package/tests/AllowedHardcodedNfts.test.ts +78 -0
- package/tests/AllowedNamecoin.test.ts +33 -0
- package/tests/AllowedOrdi.test.ts +47 -0
- package/tests/AllowedOxbt.test.ts +47 -0
- package/tests/AllowedProjectlCollection.test.ts +51 -0
- package/tests/AllowedProtocolCollection.test.ts +44 -0
- package/tests/AllowedStamps.test.ts +73 -0
- package/tests/fixtures/bells/balance-with-non-bell-first.json +14 -0
- package/tests/fixtures/bells/balance-with-non-bell.json +14 -0
- package/tests/fixtures/bells/balance.json +9 -0
- package/tests/fixtures/bitcoin-degods/balance-with-non-degods-first.json +57 -0
- package/tests/fixtures/bitcoin-degods/balance-with-non-degods.json +57 -0
- package/tests/fixtures/bitcoin-degods/balance.json +52 -0
- package/tests/fixtures/bitcoin-ordinals/balance-with-native-first.json +17 -0
- package/tests/fixtures/bitcoin-ordinals/balance-with-only-native.json +12 -0
- package/tests/fixtures/bitcoin-ordinals/balance.json +42 -0
- package/tests/fixtures/counterparty/balance-with-multiple.json +47 -0
- package/tests/fixtures/counterparty/balance.json +42 -0
- package/tests/fixtures/cursed-ordinals/balance-with-native-first.json +15 -0
- package/tests/fixtures/cursed-ordinals/balance-with-native.json +15 -0
- package/tests/fixtures/cursed-ordinals/balance.json +11 -0
- package/tests/fixtures/dogeparty/balance-with-non-dogeparty-first.json +16 -0
- package/tests/fixtures/dogeparty/balance-with-non-dogeparty.json +16 -0
- package/tests/fixtures/dogeparty/balance.json +11 -0
- package/tests/fixtures/embels/balance.json +10 -0
- package/tests/fixtures/emblem-open/balance.json +244 -0
- package/tests/fixtures/ethscriptions/balance-with-native-first.json +69 -0
- package/tests/fixtures/ethscriptions/balance-with-native.json +37 -0
- package/tests/fixtures/ethscriptions/balance.json +64 -0
- package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json +20 -0
- package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json +20 -0
- package/tests/fixtures/hardcoded-nfts/balance.json +15 -0
- package/tests/fixtures/megapunks/balance-with-non-megapunk-first.json +48 -0
- package/tests/fixtures/megapunks/balance-with-non-megapunk.json +48 -0
- package/tests/fixtures/megapunks/balance.json +43 -0
- package/tests/fixtures/namecoin/balance-with-native-first.json +109 -0
- package/tests/fixtures/namecoin/balance-with-native.json +109 -0
- package/tests/fixtures/namecoin/balance.json +103 -0
- package/tests/fixtures/ordi/balance-with-native-first.json +13 -0
- package/tests/fixtures/ordi/balance-with-native.json +13 -0
- package/tests/fixtures/ordi/balance.json +8 -0
- package/tests/fixtures/oxbt/balance-with-native-first.json +13 -0
- package/tests/fixtures/oxbt/balance-with-native.json +13 -0
- package/tests/fixtures/oxbt/balance.json +8 -0
- package/tests/fixtures/stamps/balance-with-non-stamps-first.json +23 -0
- package/tests/fixtures/stamps/balance-with-non-stamps.json +23 -0
- package/tests/fixtures/stamps/balance.json +18 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Cursed Ordinals', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Does not allow application/json content type', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
|
|
17
|
+
balanceValues[0].content_type = 'application/json'
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Does not allow incorrect coin', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
|
|
24
|
+
balanceValues[0].coin = "invalid coin"
|
|
25
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Does not allow incorrect names', async () => {
|
|
29
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
30
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
|
|
31
|
+
balanceValues[0].name = "Invalid Name"
|
|
32
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
+
|
|
34
|
+
balanceValues[0].name = "Cursed Ordinal"
|
|
35
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
36
|
+
|
|
37
|
+
balanceValues[0].name = "Cursed Ordinal InvalidNumber"
|
|
38
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
39
|
+
|
|
40
|
+
balanceValues[0].name = "Cursed Ordinal 53888"
|
|
41
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
42
|
+
|
|
43
|
+
balanceValues[0].name = "Invalid Project -53888"
|
|
44
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
45
|
+
|
|
46
|
+
balanceValues[0].name = "Cursed Ordinal -53888"
|
|
47
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('Requires first balance value to be a cursed ordinal', async () => {
|
|
51
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
52
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native-first.json"))
|
|
53
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('Allows non-cursed ordinal balances if not first', async () => {
|
|
57
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
58
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native.json"))
|
|
59
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('Allows valid coin and name', async () => {
|
|
63
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
|
|
64
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
|
|
65
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe('Allowed Function for Embels',() => {
|
|
5
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
6
|
+
|
|
7
|
+
it('Always allowed', async () => {
|
|
8
|
+
const curatedContract:any = await sdk.fetchCuratedContractByName('Embels')
|
|
9
|
+
expect(curatedContract.allowed()).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Embels', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Always returns true', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Embels')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeTruthy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeTruthy()
|
|
12
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/embels/balance.json"))
|
|
13
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for EmblemOpen', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('EmblemOpen')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Allows any asset', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('EmblemOpen')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/emblem-open/balance.json"))
|
|
17
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Ethscriptions', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Ethscription')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("Requires coin to be 'ethscription'", async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Ethscription')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ethscriptions/balance.json"))
|
|
17
|
+
balanceValues[0].coin = "invalid coin"
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Requires first balance value to be an ethscription', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Ethscription')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ethscriptions/balance-with-native-first.json"))
|
|
24
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('Allows non-ethscription balances if not first', async () => {
|
|
28
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Ethscription')
|
|
29
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ethscriptions/balance-with-native.json"))
|
|
30
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('Allows valid balances', async () => {
|
|
34
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Ethscription')
|
|
35
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ethscriptions/balance.json"))
|
|
36
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
import { NFT_DATA } from '../src/utils';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
describe('Allowed Function for Hardcoded NFTs (XCP)', () => {
|
|
7
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
8
|
+
|
|
9
|
+
it('Does not allow empty balance', async () => {
|
|
10
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
11
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
12
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('Requires asset name to be present in hardcoded metadata', async () => {
|
|
16
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
17
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
18
|
+
balanceValues[0].name = 'invalid name'
|
|
19
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('Requires projectName in hardcoded data to match curated collection name (case insensitive)', async () => {
|
|
23
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
24
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
25
|
+
const hardcodedData = NFT_DATA[balanceValues[0]['name']]
|
|
26
|
+
const validProjectName = hardcodedData['projectName']
|
|
27
|
+
let hardcodedDataCopy = hardcodedData
|
|
28
|
+
NFT_DATA[balanceValues[0]['name']]['projectName'] = validProjectName.toUpperCase()
|
|
29
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
30
|
+
|
|
31
|
+
NFT_DATA[balanceValues[0]['name']]['projectName'] = 'invalid name'
|
|
32
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
+
|
|
34
|
+
NFT_DATA[balanceValues[0]['name']]['projectName'] = validProjectName
|
|
35
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('Requires asset project to match curated collection name', async () => {
|
|
39
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
40
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
41
|
+
balanceValues[0].project = 'Invalid project'
|
|
42
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('Requires first asset balance to be 1', async () => {
|
|
46
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
47
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
48
|
+
balanceValues[0].balance = 2
|
|
49
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('Allows any coin', async () => {
|
|
53
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
54
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
55
|
+
balanceValues[0].coin = 'some coin'
|
|
56
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('Does not allow non hardcoded asset first', async () => {
|
|
60
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
61
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json"))
|
|
62
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('Allows non hardcoded assets if not first', async () => {
|
|
66
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
67
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json"))
|
|
68
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
it('Allows valid balances', async () => {
|
|
73
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Age of Chains')
|
|
74
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/hardcoded-nfts/balance.json"))
|
|
75
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Namecoin', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Namecoin')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires coin to be a native asset', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Namecoin')
|
|
16
|
+
let balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/namecoin/balance.json"))
|
|
17
|
+
balanceValues[0].coin = "invalid coin"
|
|
18
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
19
|
+
balanceValues[0].coin = null
|
|
20
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('Allows native assets and NFTs in any order', async () => {
|
|
24
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Namecoin')
|
|
25
|
+
let balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/namecoin/balance.json"))
|
|
26
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
27
|
+
balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/namecoin/balance-with-native.json"))
|
|
28
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
29
|
+
balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/namecoin/balance-with-native-first.json"))
|
|
30
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for $ORDI', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$ORDI')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires specific balance', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$ORDI')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ordi/balance.json"))
|
|
17
|
+
balanceValues[0].balance = curatedContract.balanceQty - 1
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
balanceValues[0].balance = curatedContract.balanceQty + 1
|
|
20
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('Requires specific name', async () => {
|
|
24
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$ORDI')
|
|
25
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ordi/balance.json"))
|
|
26
|
+
balanceValues[0].name = `${curatedContract.balanceQty}`
|
|
27
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
28
|
+
balanceValues[0].name = '$ORDI'
|
|
29
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
30
|
+
balanceValues[0].name = `${curatedContract.balanceQty} $ORDI`
|
|
31
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('Allows non-ordi balance if not first', async () => {
|
|
35
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$ORDI')
|
|
36
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ordi/balance-with-native.json"))
|
|
37
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('Does not allow non-ordi balance as first vaule', async () => {
|
|
41
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$ORDI')
|
|
42
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/ordi/balance-with-native-first.json"))
|
|
43
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for $OXBT', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$OXBT')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires specific balance', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$OXBT')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/oxbt/balance.json"))
|
|
17
|
+
balanceValues[0].balance = curatedContract.balanceQty - 1
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
balanceValues[0].balance = curatedContract.balanceQty + 1
|
|
20
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('Requires specific name', async () => {
|
|
24
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$OXBT')
|
|
25
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/oxbt/balance.json"))
|
|
26
|
+
balanceValues[0].name = `${curatedContract.balanceQty}`
|
|
27
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
28
|
+
balanceValues[0].name = '$ORDI'
|
|
29
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
30
|
+
balanceValues[0].name = `${curatedContract.balanceQty} $OXBT`
|
|
31
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('Allows non-oxbt balance if not first', async () => {
|
|
35
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$OXBT')
|
|
36
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/oxbt/balance-with-native.json"))
|
|
37
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('Does not allow non-oxbt balance as first vaule', async () => {
|
|
41
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('$OXBT')
|
|
42
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/oxbt/balance-with-native-first.json"))
|
|
43
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for project collections', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires first asset to have coin matching collectionChain (case insensitive)', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/megapunks/balance.json"))
|
|
17
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
18
|
+
balanceValues[0].coin = balanceValues[0].coin.toUpperCase()
|
|
19
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
20
|
+
balanceValues[0].coin = balanceValues[0].coin.toLowerCase()
|
|
21
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
22
|
+
balanceValues[0].coin = 'invalid coin'
|
|
23
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('Requires project to match collection name', async () => {
|
|
27
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
28
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/megapunks/balance.json"))
|
|
29
|
+
balanceValues[0].project = 'invalid project'
|
|
30
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('Does not allow non collection assets if first', async () => {
|
|
34
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
35
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/megapunks/balance-with-non-megapunk-first.json"))
|
|
36
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('Allows non collection assets if not first', async () => {
|
|
40
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
41
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/megapunks/balance-with-non-megapunk.json"))
|
|
42
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('Allows valid balances', async () => {
|
|
46
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('MegaPunks')
|
|
47
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/megapunks/balance.json"))
|
|
48
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for protocol collections', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Dogeparty')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires first asset to have coin matching collectionChain (case insensitive)', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Dogeparty')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/dogeparty/balance.json"))
|
|
17
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
18
|
+
balanceValues[0].coin = balanceValues[0].coin.toUpperCase()
|
|
19
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
20
|
+
balanceValues[0].coin = balanceValues[0].coin.toLowerCase()
|
|
21
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
22
|
+
balanceValues[0].coin = 'invalid coin'
|
|
23
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('Does not allow non collection asset if first', async () => {
|
|
27
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Dogeparty')
|
|
28
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/dogeparty/balance-with-non-dogeparty-first.json"))
|
|
29
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('Allows non collection assets if not first', async () => {
|
|
33
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Dogeparty')
|
|
34
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/dogeparty/balance-with-non-dogeparty.json"))
|
|
35
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('Allows valid balances', async () => {
|
|
39
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Dogeparty')
|
|
40
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/dogeparty/balance.json"))
|
|
41
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Stamps', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires asset name to include `stamps`', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
17
|
+
balanceValues[0].name = 'invalid asset name'
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Requires project name', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
24
|
+
balanceValues[0].project = null
|
|
25
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Requires project name to be Stamps or Stampunks', async () => {
|
|
29
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
30
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
31
|
+
balanceValues[0].project = 'invalid project'
|
|
32
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('Allows case insensitive project name', async () => {
|
|
36
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
37
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
38
|
+
balanceValues[0].project = 'STAMPS'
|
|
39
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
40
|
+
balanceValues[0].project = 'STAMPUNKS'
|
|
41
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('Requires coin to be a native asset', async () => {
|
|
45
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
46
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
47
|
+
balanceValues[0].coin = 'invalid coin'
|
|
48
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
49
|
+
for (var nativeAsset of curatedContract.nativeAssets) {
|
|
50
|
+
balanceValues[0].coin = nativeAsset
|
|
51
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('Requires first asset to be a stamp', async () => {
|
|
56
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
57
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance-with-non-stamps-first.json"))
|
|
58
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('Allows non-stamps assets if not first', async () => {
|
|
62
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
63
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance-with-non-stamps.json"))
|
|
64
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('Allows valid balances', async () => {
|
|
68
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Stamps')
|
|
69
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/stamps/balance.json"))
|
|
70
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"coin": "BTC",
|
|
4
|
+
"name": "BTC",
|
|
5
|
+
"balance": 1
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"coin": "ordinalsbtc",
|
|
9
|
+
"name": "DeGod #4654",
|
|
10
|
+
"balance": 1,
|
|
11
|
+
"type": "nft",
|
|
12
|
+
"external_url": "https://ordinals.com/inscription/4e80a569505ced2e72d48e9f79832ba487a64716c9a77b7189d6b6f1b3f95694i0",
|
|
13
|
+
"image": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/4e80a569505ced2e72d48e9f79832ba487a64716c9a77b7189d6b6f1b3f95694i0",
|
|
14
|
+
"project": "DeGods",
|
|
15
|
+
"projectLogo": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/d8c2e6fca21b41817dc162445f2a0c0f5b0995c0cae12799a39571cd974c4ea2i0",
|
|
16
|
+
"traits": [
|
|
17
|
+
{
|
|
18
|
+
"value": "Purple",
|
|
19
|
+
"trait_type": "background"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"value": "Marble",
|
|
23
|
+
"trait_type": "skin"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"value": "Earring",
|
|
27
|
+
"trait_type": "specialty"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"value": "Tourist Tee",
|
|
31
|
+
"trait_type": "clothes"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"value": "None",
|
|
35
|
+
"trait_type": "neck"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"value": "Bleached",
|
|
39
|
+
"trait_type": "head"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"value": "None",
|
|
43
|
+
"trait_type": "eyes"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"value": "Vape God",
|
|
47
|
+
"trait_type": "mouth"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"value": "DeadGod",
|
|
51
|
+
"trait_type": "version"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"price": 0,
|
|
55
|
+
"percentage": 0
|
|
56
|
+
}
|
|
57
|
+
]
|