Skip to content

Commit

Permalink
Merge pull request #26 from klayrHQ/k8s
Browse files Browse the repository at this point in the history
K8s
  • Loading branch information
Theezr committed Jun 3, 2024
2 parents 3b13273 + b395df5 commit f2154d4
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 20 deletions.
1 change: 1 addition & 0 deletions guides/token-factory/backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ config.local.json

# Build Directory
dist
k8s/secrets
4 changes: 3 additions & 1 deletion guides/token-factory/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ RUN npm install
COPY . .
RUN npm run build

CMD [ "./bin/run", "start", "--config", "config/custom_deploy_config.json", "--overwrite-config" ]
CMD [ "./bin/run", "start", "--config", "config/custom_deploy_config.json", "--overwrite-config" ]


10 changes: 5 additions & 5 deletions guides/token-factory/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ npm run build && ./bin/run start --config config/custom_config.json --overwrite-

```
./bin/run endpoint:invoke token_getBalances '{"address":"kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --pretty
./bin/run endpoint:invoke token_getBalance '{"tokenID": "1234567800000000", "address":"kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --pretty
./bin/run endpoint:invoke token_getBalance '{"tokenID": "0123456700000000", "address":"kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --pretty
```

### Commands

```
./bin/run endpoint:invoke token_getBalances '{"address":"kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --pretty
./bin/run endpoint:invoke token_getBalance '{"tokenID": "1234567800000000", "address":"klyjzyvbewx5huzs8pyw4gqeb59ekmn3fg9qhoqqz"}' --pretty
./bin/run endpoint:invoke token_getBalance '{"tokenID": "0123456700000000", "address":"klyjzyvbewx5huzs8pyw4gqeb59ekmn3fg9qhoqqz"}' --pretty
```

### Create token
Expand All @@ -47,19 +47,19 @@ npm run build && ./bin/run start --config config/custom_config.json --overwrite-
### Mint

```
./bin/run transaction:create tokenFactory mint 10000000 --params='{"tokenID": "1234567800000001", "amount": "100000000", "recipient": "kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --json --pretty
./bin/run transaction:create tokenFactory mint 10000000 --params='{"tokenID": "0123456700000001", "amount": "100000000", "recipient": "kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --json --pretty
```

### Burn

```
./bin/run transaction:create tokenFactory burn 10000000 --params='{"tokenID": "1234567800000001", "amount": "9999", "recipient": "kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --json --pretty
./bin/run transaction:create tokenFactory burn 10000000 --params='{"tokenID": "0123456700000001", "amount": "9999", "recipient": "kly4mba244me87reyg9fegcy2cesdfw6gq9r8we5x"}' --json --pretty
```

### Batch Transfer

```
./bin/run transaction:create tokenFactory batchTransfer 10000000 --params='{"tokenID": "1234567800000000", "recipients": [{"recipient": "klys9u6yy466q2mpbj92cmbp64eg7gvpuz7v4efm8", "amount": "9999"}, {"recipient": "klyjzyvbewx5huzs8pyw4gqeb59ekmn3fg9qhoqqz", "amount": "9999"}]}' --json --pretty
./bin/run transaction:create tokenFactory batchTransfer 10000000 --params='{"tokenID": "0123456700000000", "recipients": [{"recipient": "klys9u6yy466q2mpbj92cmbp64eg7gvpuz7v4efm8", "amount": "9999"}, {"recipient": "klyjzyvbewx5huzs8pyw4gqeb59ekmn3fg9qhoqqz", "amount": "9999"}]}' --json --pretty
```

### Batch Transfer test script
Expand Down
8 changes: 4 additions & 4 deletions guides/token-factory/backend/config/custom_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"port": 7887,
"host": "127.0.0.1",
"allowedMethods": ["*"],
"accessControlAllowOrigin": "*"
"accessControlAllowOrigin": "*"
},
"network": {
"version": "1.0",
Expand All @@ -30,7 +30,7 @@
"blockTime": 10,
"bftBatchSize": 103,
"maxTransactionsSize": 15360,
"chainID": "12345678"
"chainID": "01234567"
},
"generator": {
"keys": {
Expand All @@ -45,14 +45,14 @@
"plugins": {
"token_factory": {
"syncInterval": 10000,
"chainID": "12345678"
"chainID": "01234567"
},
"dashboard": {
"port": 5000,
"host": "0.0.0.0"
},
"faucet": {
"tokenID": "1234567800000000",
"tokenID": "0123456700000000",
"encryptedPrivateKey": "kdf=argon2id&cipher=aes-128-gcm&version=1&ciphertext=a0b91e022c791cc9a157536c8af79a2d3dd4b1cc0604a36e6042db2978795fe649836ccf3d92b7ce8c119005d7b3ce44a4004ef8d2744fb75dca8f91b11d418374beb0d1019331d6962cd9444f410275bb7009ab183b0032d99130a70f1013da1fc973569b2c01a9e891b0014e0d727f42713e5f52446f6059d7a53290e8ac5d&mac=c0d21b0fea79e589599f7fba768c3d7d833a0b9c52de4670ee9106ab867fabf7&salt=f0c0b45de9926f86&iv=dd952cc598feb846167e54e117292066&tag=ef8211e2d124b084297205a41f0dc101&iterations=1&parallelism=4&memorySize=2097023",
"captchaSecretkey": "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe",
"captchaSitekey": "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI",
Expand Down
4 changes: 2 additions & 2 deletions guides/token-factory/backend/config/custom_deploy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"blockTime": 10,
"bftBatchSize": 103,
"maxTransactionsSize": 15360,
"chainID": "12345678"
"chainID": "01234567"
},
"generator": {
"keys": {
Expand All @@ -45,7 +45,7 @@
"plugins": {
"token_factory": {
"syncInterval": 10000,
"chainID": "12345678"
"chainID": "01234567"
},
"dashboard": {
"port": 5000,
Expand Down
2 changes: 1 addition & 1 deletion guides/token-factory/backend/config/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"blockTime": 10,
"bftBatchSize": 103,
"maxTransactionsSize": 15360,
"chainID": "12345678"
"chainID": "01234567"
},
"generator": {
"keys": {
Expand Down
108 changes: 108 additions & 0 deletions guides/token-factory/backend/k8s/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: token-factory-deployment
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: token-factory
template:
metadata:
labels:
app: token-factory
spec:
containers:
- name: token-factory
ports:
- containerPort: 5000
image: ghcr.io/klayrhq/klayr-sdk-examples:v0.0.4-token-factory.11
imagePullPolicy: Always
# volumeMounts:
# - name: storage
# mountPath: /root/.klayr
imagePullSecrets:
- name: dockerconfigjson-github-com
# volumes:
# - name: storage
# persistentVolumeClaim:
# claimName: token-factory-pvc
---
apiVersion: v1
kind: Service
metadata:
name: chain-service
namespace: default
spec:
selector:
app: token-factory
ports:
- protocol: TCP
port: 80
targetPort: 7887
---
apiVersion: v1
kind: Service
metadata:
name: chain-faucet
namespace: default
spec:
selector:
app: token-factory
ports:
- protocol: TCP
port: 8080
targetPort: 4004
---
apiVersion: v1
kind: Service
metadata:
name: chain-service-dashboard
namespace: default
spec:
selector:
app: token-factory
ports:
- protocol: TCP
port: 8800
targetPort: 5000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
namespace: default
spec:
ingressClassName: traefik
rules:
- host: token-factory.klayr.dev
http:
paths:
- pathType: Prefix
path: '/'
backend:
service:
name: chain-service
port:
number: 80
- host: token-factory-faucet.klayr.dev
http:
paths:
- pathType: Prefix
path: '/'
backend:
service:
name: chain-faucet
port:
number: 8080
- host: token-factory-dash.klayr.dev
http:
paths:
- pathType: Prefix
path: '/'
backend:
service:
name: chain-service-dashboard
port:
number: 8800
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const configSchema = {
required: ['syncInterval', 'chainID'],
default: {
syncInterval: 20000, // milliseconds
chainID: '12345678',
chainID: '01234567',
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cryptography } from 'klayr-sdk';

function generateParams() {
const tokenID = '1234567800000000';
const tokenID = '0123456700000000';
const numberOfTransfers = 20;
const maxAmount = 100;

Expand Down
2 changes: 1 addition & 1 deletion guides/token-factory/backend/test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class TokenID {

return Buffer.concat([
// default genesis chainID
Buffer.from('12345678'),
Buffer.from('01234567'),
tokenIDBuffer,
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CommandExecuteContext, Transaction, VerifyStatus, chain, codec, db } fr
describe('BurnCommand', () => {
const initConfig = {
minAmountToBurn: BigInt(1000),
chainID: Buffer.from('12345678'),
chainID: Buffer.from('01234567'),
};
const tokenID = new TokenID(1).toBuffer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('CreateTokenCommand', () => {
maxNameLength: 30,
maxSymbolLength: 6,
maxTotalSupply: BigInt(1e6),
chainID: Buffer.from('12345678'),
chainID: Buffer.from('01234567'),
createTokenFee: BigInt(100_000),
};
const defaultToken = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('MintCommand', () => {
const initConfig = {
minAmountToMint: BigInt(1000),
maxAmountToMint: BigInt(1e6) * BigInt(1e8),
chainID: Buffer.from('12345678'),
chainID: Buffer.from('01234567'),
createTokenFee: BigInt(100_000),
};
const tokenID = new TokenID(1).toBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TokenFactoryModule } from '@app/modules/token_factory/module';

describe('TokenFactoryModule', () => {
const genesisConfig: any = {
chainID: '12345678',
chainID: '01234567',
};
const defaultConfig = {
maxNameLength: 30,
Expand Down

0 comments on commit f2154d4

Please sign in to comment.