@flowtyio/flow-contracts 0.0.7 → 0.0.10
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/README.md +13 -1
- package/add.js +2 -2
- package/contracts/hybrid-custody/CapabilityDelegator.cdc +174 -0
- package/contracts/hybrid-custody/CapabilityFactory.cdc +105 -0
- package/contracts/hybrid-custody/CapabilityFilter.cdc +199 -0
- package/contracts/hybrid-custody/HybridCustody.cdc +1202 -0
- package/contracts/hybrid-custody/factories/FTAllFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/FTBalanceFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/FTProviderFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/FTReceiverBalanceFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/FTReceiverFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/NFTCollectionPublicFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc +10 -0
- package/contracts/hybrid-custody/factories/NFTProviderFactory.cdc +10 -0
- package/find.js +26 -0
- package/flow.json +77 -0
- package/index.js +0 -2
- package/package.json +2 -2
- package/utils.js +2 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "FungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract FTAllFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{FungibleToken.Provider, FungibleToken.Balance, FungibleToken.Receiver}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "FungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract FTBalanceFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{FungibleToken.Balance}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "FungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract FTProviderFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{FungibleToken.Provider}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "FungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract FTReceiverBalanceFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{FungibleToken.Receiver, FungibleToken.Balance}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "FungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract FTReceiverFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{FungibleToken.Receiver}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "NonFungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract NFTCollectionPublicFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{NonFungibleToken.CollectionPublic}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "NonFungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract NFTProviderAndCollectionFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "CapabilityFactory"
|
|
2
|
+
import "NonFungibleToken"
|
|
3
|
+
|
|
4
|
+
pub contract NFTProviderFactory {
|
|
5
|
+
pub struct Factory: CapabilityFactory.Factory {
|
|
6
|
+
pub fun getCapability(acct: &AuthAccount, path: CapabilityPath): Capability {
|
|
7
|
+
return acct.getCapability<&{NonFungibleToken.Provider}>(path)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
package/find.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const findFileInDirectory = (directoryPath, fileNameToFind) => {
|
|
5
|
+
const files = fs.readdirSync(directoryPath);
|
|
6
|
+
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
const filePath = path.join(directoryPath, file);
|
|
9
|
+
const stats = fs.statSync(filePath);
|
|
10
|
+
|
|
11
|
+
if (stats.isFile() && file === fileNameToFind) {
|
|
12
|
+
return filePath;
|
|
13
|
+
} else if (stats.isDirectory()) {
|
|
14
|
+
const foundFilePath = findFileInDirectory(filePath, fileNameToFind);
|
|
15
|
+
if (foundFilePath) {
|
|
16
|
+
return foundFilePath;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return null; // File not found
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
findFileInDirectory
|
|
26
|
+
}
|
package/flow.json
CHANGED
|
@@ -47,6 +47,83 @@
|
|
|
47
47
|
"testnet": "0x631e88ae7f1d7c20",
|
|
48
48
|
"mainnet": "0x1d7e57aa55817448"
|
|
49
49
|
}
|
|
50
|
+
},
|
|
51
|
+
"HybridCustody": {
|
|
52
|
+
"source": "./contracts/hybrid-custody/HybridCustody.cdc",
|
|
53
|
+
"aliases": {
|
|
54
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
55
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"CapabilityFactory": {
|
|
59
|
+
"source": "./contracts/hybrid-custody/CapabilityFactory.cdc",
|
|
60
|
+
"aliases": {
|
|
61
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
62
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"CapabilityDelegator": {
|
|
66
|
+
"source": "./contracts/hybrid-custody/CapabilityDelegator.cdc",
|
|
67
|
+
"aliases": {
|
|
68
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
69
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"CapabilityFilter": {
|
|
73
|
+
"source": "./contracts/hybrid-custody/CapabilityFilter.cdc",
|
|
74
|
+
"aliases": {
|
|
75
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
76
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"FTAllFactory": {
|
|
80
|
+
"source": "./contracts/hybrid-custody/factories/FTAllFactory.cdc",
|
|
81
|
+
"aliases": {
|
|
82
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
83
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"FTBalanceFactory": {
|
|
87
|
+
"source": "./contracts/hybrid-custody/factories/FTBalanceFactory.cdc",
|
|
88
|
+
"aliases": {
|
|
89
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
90
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"FTProviderFactory": {
|
|
94
|
+
"source": "./contracts/hybrid-custody/factories/FTProviderFactory.cdc",
|
|
95
|
+
"aliases": {
|
|
96
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
97
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"FTReceiverFactory": {
|
|
101
|
+
"source": "./contracts/hybrid-custody/factories/FTReceiverFactory.cdc",
|
|
102
|
+
"aliases": {
|
|
103
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
104
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"NFTCollectionPublicFactory": {
|
|
108
|
+
"source": "./contracts/hybrid-custody/factories/NFTCollectionPublicFactory.cdc",
|
|
109
|
+
"aliases": {
|
|
110
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
111
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"NFTProviderAndCollectionPublicFactory": {
|
|
115
|
+
"source": "./contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc",
|
|
116
|
+
"aliases": {
|
|
117
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
118
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"NFTProviderFactory": {
|
|
122
|
+
"source": "./contracts/hybrid-custody/factories/NFTProviderFactory.cdc",
|
|
123
|
+
"aliases": {
|
|
124
|
+
"emulator": "0xf8d6e0586b0a20c7",
|
|
125
|
+
"testnet": "0x294e44e1ec6993c6"
|
|
126
|
+
}
|
|
50
127
|
}
|
|
51
128
|
},
|
|
52
129
|
"deployments": {
|
package/index.js
CHANGED
|
@@ -32,8 +32,6 @@ program.command("add-all")
|
|
|
32
32
|
.option('-c, --config <config>', 'File location of the config to be edited')
|
|
33
33
|
.option('-a, --account <account>', 'Account to be used for signing', 'emulator-account')
|
|
34
34
|
.action(({config, account}) => {
|
|
35
|
-
console.log("config: ", config, "account: ", account)
|
|
36
|
-
|
|
37
35
|
if(!config) {
|
|
38
36
|
options.config = getDefaultConfigPath()
|
|
39
37
|
console.log("no config specified, using default config: ", options.config)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowtyio/flow-contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"main": "index.json",
|
|
5
5
|
"description": "An NPM package for common flow contracts",
|
|
6
6
|
"author": "flowtyio",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"*.js",
|
|
30
30
|
"index.json",
|
|
31
|
-
"contracts
|
|
31
|
+
"contracts/**/*.cdc",
|
|
32
32
|
"flow.json",
|
|
33
33
|
"README.md",
|
|
34
34
|
"LICENSE"
|
package/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
|
+
const {findFileInDirectory} = require("./find");
|
|
2
3
|
|
|
3
4
|
const getDefaultConfigPath = () => {
|
|
4
5
|
const currentWorkingDirectory = process.cwd();
|
|
@@ -15,7 +16,7 @@ const getConfig = (path) => {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const getContractCode = (contractName) => {
|
|
18
|
-
const path = `${__dirname}/contracts
|
|
19
|
+
const path = findFileInDirectory(`${__dirname}/contracts`, `${contractName}.cdc`)
|
|
19
20
|
return fs.readFileSync(path, 'utf8')
|
|
20
21
|
}
|
|
21
22
|
|