Skip to content

Commit

Permalink
Merge pull request #788 from DaddyWesker/update_snet_gate
Browse files Browse the repository at this point in the history
Update snet gate
  • Loading branch information
Necr0x0Der authored Nov 15, 2024
2 parents 7035497 + 9732ad0 commit 615e464
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
28 changes: 11 additions & 17 deletions python/hyperon/exts/snet_io/snet_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,13 @@ def init_sdk(self,
private_key=os.getenv("SNET_PRIVATE_KEY", '0' * 32),
eth_rpc_endpoint=os.getenv("ETH_RPC_ENDPOINT"),
email=os.getenv("SNET_EMAIL"),
identity_name="hyperon",
network="mainnet",
identity_type="key",
concurrency=False,
force_update=False):
config = {
"private_key": private_key,
"eth_rpc_endpoint": eth_rpc_endpoint,
"email": email,
"concurrency": concurrency,
"identity_name": identity_name,
"network": network,
"identity_type": identity_type,
"force_update": force_update
}
self.email = email
config = sdk.config.Config(private_key=private_key,
eth_rpc_endpoint=eth_rpc_endpoint,
concurrency=concurrency,
force_update=force_update)
self.snet_sdk = sdk.SnetSDK(config)

def organization_list(self):
Expand All @@ -45,6 +37,7 @@ def create_service_client(self, org_id, service_id,
service_client = self.snet_sdk.create_service_client(
org_id=org_id, service_id=service_id,
# group_name="default_group",
email=self.email,
free_call_auth_token_bin=free_call_auth_token_bin,
free_call_token_expiry_block=free_call_token_expiry_block)
return ServiceCall(service_client)
Expand Down Expand Up @@ -191,13 +184,14 @@ def get_service_messages(self):
def get_operation_atom(self):
return OperationAtom(self.service_details[1], self)

def generate_callers_text(self):
return pretty_print_atoms(self.generate_callers())

def open_channel_and_deposit(self, amount, expiration):
self.service_client.deposit_and_open_channel(amount, expiration)
return [E()]

def generate_callers_text(self):
# TODO: pretty print
return "\n".join([repr(e) for e in self.generate_callers()])

def _map_type(self, t):
type_map = {'bool': 'Bool',
'string': 'String',
Expand Down Expand Up @@ -241,4 +235,4 @@ def snet_atoms():
# TODO: new-sdk-atom
return {
'snet-sdk': defaultSDKAtom,
}
}
5 changes: 1 addition & 4 deletions python/hyperon/exts/snet_io/test_snet_call.metta
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,4 @@
(gen_gpt_2 "What was the largest dinosaur?" "universal" 0.5 2 100)

; possible usage of open_channel_and_deposit function. 100 is the amount of AGIX and 10000 is a payment channel's TTL in blocks
(snet-sdk open_channel_and_deposit &generative-lms 100 10000)

; usage of generate_callers_text method
((py-dot &generative-lms generate_callers_text))
(snet-sdk open_channel_and_deposit &generative-lms 100 10000)
3 changes: 1 addition & 2 deletions python/hyperon/exts/snet_io/test_snet_meta.metta
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
; (naint punctuation-restoration) returns a service caller now
!((py-dot (naint punctuation-restoration) get_service_messages))
; we can also get a list of all service methods as typed metta functions
!(naint punctuation-restoration methods)

!(naint punctuation-restoration methods)

0 comments on commit 615e464

Please sign in to comment.