-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(fuel): add fuel template files (#764)
- Loading branch information
1 parent
023fd16
commit 40cd115
Showing
8 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
272 changes: 272 additions & 0 deletions
272
packages/cli/templates/fuel/abis/fuel/counter-contract-abi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,272 @@ | ||
{ | ||
"encoding": "1", | ||
"types": [ | ||
{ | ||
"typeId": 0, | ||
"type": "()", | ||
"components": [], | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 1, | ||
"type": "b256", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 2, | ||
"type": "bool", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 3, | ||
"type": "enum ColorError", | ||
"components": [ | ||
{ | ||
"name": "Blue", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Green", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Red", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Other", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
], | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 4, | ||
"type": "enum Option", | ||
"components": [ | ||
{ | ||
"name": "None", | ||
"type": 0, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Some", | ||
"type": 7, | ||
"typeArguments": null | ||
} | ||
], | ||
"typeParameters": [7] | ||
}, | ||
{ | ||
"typeId": 5, | ||
"type": "enum Result", | ||
"components": [ | ||
{ | ||
"name": "Ok", | ||
"type": 7, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "Err", | ||
"type": 6, | ||
"typeArguments": null | ||
} | ||
], | ||
"typeParameters": [7, 6] | ||
}, | ||
{ | ||
"typeId": 6, | ||
"type": "generic E", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 7, | ||
"type": "generic T", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 8, | ||
"type": "str[1]", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 9, | ||
"type": "str[25]", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 10, | ||
"type": "struct Foo", | ||
"components": [ | ||
{ | ||
"name": "bar", | ||
"type": 12, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "baz", | ||
"type": 2, | ||
"typeArguments": null | ||
} | ||
], | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 11, | ||
"type": "u32", | ||
"components": null, | ||
"typeParameters": null | ||
}, | ||
{ | ||
"typeId": 12, | ||
"type": "u64", | ||
"components": null, | ||
"typeParameters": null | ||
} | ||
], | ||
"functions": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "foo", | ||
"type": 10, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "option", | ||
"type": 4, | ||
"typeArguments": [ | ||
{ | ||
"name": "", | ||
"type": 8, | ||
"typeArguments": null | ||
} | ||
] | ||
} | ||
], | ||
"name": "complex", | ||
"output": { | ||
"name": "", | ||
"type": 5, | ||
"typeArguments": [ | ||
{ | ||
"name": "", | ||
"type": 10, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "", | ||
"type": 3, | ||
"typeArguments": null | ||
} | ||
] | ||
}, | ||
"attributes": [ | ||
{ | ||
"name": "storage", | ||
"arguments": ["read", "write"] | ||
} | ||
] | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "count", | ||
"output": { | ||
"name": "", | ||
"type": 12, | ||
"typeArguments": null | ||
}, | ||
"attributes": [ | ||
{ | ||
"name": "storage", | ||
"arguments": ["read"] | ||
} | ||
] | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "add", | ||
"type": 11, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "two", | ||
"type": 12, | ||
"typeArguments": null | ||
}, | ||
{ | ||
"name": "three", | ||
"type": 1, | ||
"typeArguments": null | ||
} | ||
], | ||
"name": "increment", | ||
"output": { | ||
"name": "", | ||
"type": 12, | ||
"typeArguments": null | ||
}, | ||
"attributes": [ | ||
{ | ||
"name": "storage", | ||
"arguments": ["read", "write"] | ||
} | ||
] | ||
} | ||
], | ||
"loggedTypes": [ | ||
{ | ||
"logId": "1515152261580153489", | ||
"loggedType": { | ||
"name": "", | ||
"type": 12, | ||
"typeArguments": null | ||
} | ||
}, | ||
{ | ||
"logId": "9006093109815063660", | ||
"loggedType": { | ||
"name": "", | ||
"type": 10, | ||
"typeArguments": [] | ||
} | ||
}, | ||
{ | ||
"logId": "14631882454972838106", | ||
"loggedType": { | ||
"name": "", | ||
"type": 9, | ||
"typeArguments": null | ||
} | ||
}, | ||
{ | ||
"logId": "15520703124961489725", | ||
"loggedType": { | ||
"name": "", | ||
"type": 11, | ||
"typeArguments": null | ||
} | ||
}, | ||
{ | ||
"logId": "8961848586872524460", | ||
"loggedType": { | ||
"name": "", | ||
"type": 1, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"messagesTypes": [], | ||
"configurables": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"private": true, | ||
"name": "template-fuel", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"build": "sentio build", | ||
"gen": "sentio gen", | ||
"test": "sentio test", | ||
"upload": "sentio upload" | ||
}, | ||
"dependencies": { | ||
"@sentio/sdk": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@sentio/cli": "workspace:*", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
project: fuel-counter | ||
host: http://localhost:10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { TestProcessorServer } from '@sentio/sdk/testing' | ||
|
||
describe('Test Processor', () => { | ||
const service = new TestProcessorServer(async () => await import('./processor.js')) | ||
|
||
beforeAll(async () => { | ||
await service.start() | ||
}) | ||
|
||
test('has config', async () => { | ||
const config = await service.getConfig({}) | ||
expect(config.contractConfigs.length > 0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { LogLevel } from '@sentio/sdk' | ||
import { FuelProcessor, FuelNetwork } from '@sentio/sdk/fuel' | ||
|
||
import abi from '../abis/fuel/counter-contract-abi.json' | ||
import { CounterContractProcessor } from './types/fuel/CounterContractProcessor.js' | ||
|
||
FuelProcessor.bind({ | ||
address: '0xa14f85860d6ce99154ecbb13570ba5fba1d8dc16b290de13f036b016fd19a29c', | ||
chainId: FuelNetwork.TEST_NET, | ||
abi | ||
}) | ||
.onTransaction( | ||
async (tx, ctx) => { | ||
ctx.eventLogger.emit('transaction', { | ||
distinctId: tx.id, | ||
message: 'Transaction processed', | ||
properties: { | ||
fee: tx.fee.toNumber() | ||
}, | ||
severity: tx.status === 'success' ? LogLevel.INFO : LogLevel.ERROR | ||
}) | ||
}, | ||
{ includeFailed: true } | ||
) | ||
.onCall('increment', async (call, ctx) => { | ||
const args = call.functionScopes[0]?.getCallConfig()?.args as any[] | ||
ctx.eventLogger.emit('increment', { | ||
distinctId: ctx.transaction?.id, | ||
message: 'increment', | ||
properties: { | ||
arg0: String(args[0]), | ||
arg1: String(args[1]), | ||
arg2: String(args[2]), | ||
ret: String(call.value) | ||
}, | ||
severity: ctx.transaction?.status === 'success' ? LogLevel.INFO : LogLevel.ERROR | ||
}) | ||
}) | ||
|
||
CounterContractProcessor.bind({ | ||
address: '0xa14f85860d6ce99154ecbb13570ba5fba1d8dc16b290de13f036b016fd19a29c', | ||
chainId: FuelNetwork.TEST_NET | ||
}).onCallComplex(async (call, ctx) => { | ||
const [arg1, arg2] = call.args | ||
const { Ok, Err } = call.returnValue | ||
ctx.eventLogger.emit('increment', { | ||
distinctId: ctx.transaction?.id, | ||
message: 'complex', | ||
properties: { | ||
baz: arg1.baz, | ||
bar: arg1.bar, | ||
arg2: arg2, | ||
ret: String(Ok), | ||
error: Err | ||
}, | ||
severity: ctx.transaction?.status === 'success' ? LogLevel.INFO : LogLevel.ERROR | ||
}) | ||
}, {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
}, | ||
"exclude": ["dist", "jest.config.ts"], | ||
"extends": "../../tsconfig.json" | ||
} |
Oops, something went wrong.